I have a view in Ember.js that looks like:
MyApp.LoginView = Ember.View.extend({
templateName: 'login',
didInsertElement: function() {
$("body").addClass("light-bg");
$("footer").css("display", "none");
$("input[name=email]").focus();
},
willDestroyElement: function() {
$("body").removeClass("light-bg");
$("footer").css("display", "block");
}
});
I need another view which is exactly the same, except it is called ForgotPassword, thus the only difference is the templateName.
Is there a way in Ember.js, I can say ForgotPassword inherits Login, and then just set templateName to forgotPassword?
Thanks.
didInsertElement/willDestroyElement, you should only be directly manipulating DOM elements that this this view's element or descendants, and when you do, usethis.$(). e.g.this.$('input[name=email]'). - Luke Melia