CoreObject#init()

initpublic

Defined in packages/ember-runtime/lib/system/core_object.js:217

An overridable method called when objects are instantiated. By default, does nothing unless it is overridden during class definition.

Example:

1
2
3
4
5
6
7
8
9
10
11
App.Person = Ember.Object.extend({
  init: function() {
    alert('Name is ' + this.get('name'));
  }
});
 
var steve = App.Person.create({
  name: "Steve"
});
 
// alerts 'Name is Steve'.

NOTE: If you do override init for a framework class like Ember.View, be sure to call this._super(...arguments) in your init declaration! If you don't, Ember may not have an opportunity to do important setup work, and you'll see strange behavior in your application.

doc_EmberJs
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.