我是EmberJS的新手并拥有现有代码。 我有一个登录表单,应该在按下回车键时发布。
第一次一切顺利并按预期工作,一旦我退出 - 它清除会话并将我重定向到登录视图,然后问题开始,因为that.get("controller")
这次未定义。
我的登录视图的代码如下
didInsertElement: function () {
var that = this;
Ember.$(document).keyup(function (e) {
if (e.which == 13) {
that.get("controller").send("login");
// **As that.get("controller") is undefined I want to set that**
//that.set("controller"); //- **CAN I DO THIS?**
}
});
}
我的问题是 - that.get("controller")
是undefined
。
当我尝试that.set("controller");
时 - 它说
断言失败:在被破坏的对象上调用set