Backbone.js:重置集合会导致 model.save 出现错误
我有一个网络应用程序,我正在其中实现文件夹列表。每当单击文件夹时,都会显示其内容。
单击各个文件夹并显示其内容后,我发现在文件夹项上触发事件,多个模型正在响应该事件 - 更改文件夹时,出现在多个列表中的列表项的模型不会被删除。
因此,我开始使用此函数来删除文件夹中的列表项集合。
this.collection.reset()
我的问题已经解决了,但是现在当我尝试将模型持久化到数据库时,我总是收到以下错误...
A "url" property or function must be specified
知道为什么这是由 this.collection.reset()
引起的吗???
I have a webapp where I am implementing a list of folders. Whenever a folder is clicked, it contents are shown.
After clicking on various folders, thus displaying their contents, I found out that triggering an event on a folder item, multiple models were responding to the event - models for list item appearing in more than one list were not removed when changing folders.
So, I started using this function to remove the collection of list items in a folder.
this.collection.reset()
my problem was solved but now when I try to persist a model to db, I always get the following error...
A "url" property or function must be specified
any idea why this is being caused by this.collection.reset()
???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,您在某处有一个事件绑定,当触发
reset
事件时,该事件绑定会调用fetch()
。在代码中查找任何bind('reset', ...)
语句。Most likely, you have an event binding somewhere that calls
fetch()
whenreset
event is triggered. Look for anybind('reset', ...)
statements in your code.