backbone.js 绑定事件未委托给视图
当我在模型上调用 save 方法时,服务器会从数据库返回对象的新版本(即使保存时出现错误)。
在我的模型中,我有:
this.bind("change", function() {
console.log('CHANGED MODEL');
});
在我看来,我有:
this.model.bind('change', function() {
console.log('CHANGED MODEL IN VIEW');
});
当我调用保存方法时,我只从模型(更改的模型)获取日志,由于某种原因,更改事件没有委托给视图。
我错过了什么吗?我一生都无法弄清楚为什么视图中的更改事件没有被调用,而模型中的更改事件却被调用了。
一如既往,我们非常感谢任何帮助。
When I call the save method on my model the server returns me a new version of the object from the database (even if there have been errors whilst saving).
In my model I have:
this.bind("change", function() {
console.log('CHANGED MODEL');
});
In my view I have:
this.model.bind('change', function() {
console.log('CHANGED MODEL IN VIEW');
});
When I invoke the save method I only get the log from the model (CHANGED MODEL), for some reason the change event is not delegated to the view.
Am I missing something? I cannot for the life of me figure out why the change event in the view is not called when the one in the model is.
Any help is as always muchly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您似乎忘记了使用模型配置视图:
如果我错了,您将不得不为我们提供更多代码。
It seems to me that you've forgotten to configure the view with the model:
If I'm wrong, you'll have to give us more code.