I've been going through the Ember documentation and am seeing an inconsistency in where the _super
method is being called when overriding init
.
This is the most common and is what I've been using so far
var Foo = Em.Object.extend({
init: function(){
this._super();
// ... my stuff ...
}
});
last night I was reading through this write up and saw an example doing this
var Bar = Em.Object.extend({
init: function(){
// ... my stuff ...
return this._super();
}
});
It was actually an Ember.ContainerView
in the code snippet.
Can anyone explain this? My code OCD is acting up and I can't move on until I know.
You can use the --proxy option of ember-cli to proxy all requests made to your ember development server that are not handled by ember to your backend. This is a good way to do this because from the view of your application and browser your backend and your application are on the same host.
Ember has been an enabler of great productivity for many teams for almost a decade and I'm sure it's going to continue to be that. It's changed and improved a lot since its first release and is now in better shape than ever with its Octane edition.
Ember is so hard to learn, I've been really struggling with it for the last six weeks. As regards getting the libraries to work, I hope this doesn't sound obvious but I recommend you download the ember starter kit from http://emberjs.com/ and start working from within that instead.
Ember uses templates to organize the layout of HTML in an application. Ember templates use the syntax of Handlebars templates. Anything that is valid Handlebars syntax is valid Ember syntax. Here, {{name}} is a property provided by the template's context.
In the documentation linked
init: function() {
var childViews = this.get('childViews');
var descriptionView = App.DescriptionView.create();
childViews.pushObject(descriptionView);
this.addButton();
return this._super();
},
_super()
is called AFTER the descriptionView is created and pushed onto the childViews
array.
That's because the superclass init
implementation is going to take the childViews array and do stuff with it. If you called _super
before adding the descriptionView
to the array, it wouldn't get processed by whatever init
does....
I'm inferring, but that's the way it works in Sproutcore, from which Ember derives, so I think it's probably the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With