1
繼承一個觀點我在Ember.js一種觀點認爲是這樣的:如何Ember.js
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");
}
});
我需要另一種觀點認爲這是完全一樣的,只是它被稱爲ForgotPassword
,因此只區別在於templateName
。
有沒有在Ember.js中的方法,我可以說ForgotPassword
繼承Login
,然後只需將templateName設置爲forgotPassword
?
謝謝。
順便說一句,在你的'didInsertElement' /'willDestroyElement',你只能直接操作DOM元素,這這種觀點的元素或後裔,當你這樣做時,使用'this。$()'。例如'這一點。$( '輸入[名稱=郵件]')'。 – 2013-05-13 02:45:08