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:

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
2016-11-30 16:49:00
Comments
Leave a Comment

Please login to continue.