骨干localStorage的:无法读取属性未定义'递延' [英] Backbone localstorage: Cannot read property 'Deferred' of undefined
问题描述
我试图让与localStorage的插件骨干应用的工作。我包括骨干库后,库。
I am trying to make a backbone application work with the localstorage plugin. I included the library after the backbone library.
我添加了以下行来我的收藏:
I added the following line to my collection:
window.ProductCollection = Backbone.Collection.extend({
model:Product,
localStorage: new Backbone.LocalStorage("ProductCollection")
});
我不断收到来自backbone.localstorage.js以下错误:
的无法读取的'递延'属性未定义的
有什么我忘了在库的实现呢? 文档说,你只需要在localStorage的添加到您的收藏。
Is there anything i forgot to do in the implementation of the library? Documentation says you only need to add the localstorage to your collection.
推荐答案
我固定的小提琴,尽管我在另一个线程说,这是一个有点faff的!你的错误是跟你导入库为了做到(骨干取决于下划线和jQuery, Backbone.LocalStorage
依托骨干)。凑了小提琴的顺序正确的最可靠的方法是为了增加CDN链接到外部资源的标签。
I fixed your fiddle, and despite what I said in the other thread, it was a bit of a faff! Your error was to do with the order you were importing the libraries (Backbone depends on Underscore and jQuery, Backbone.LocalStorage
relies on Backbone). The most reliable way of getting the order right in the fiddle was to add the CDN links in order to the external resources tab.
您code是没有错误的运行我在Chrome和我可以检查保存到使用开发工具的资源选项卡本地存储的数据。我建议检查你使用的各种库的所有最新版本在您的本地版本。
Your code is running for me in Chrome with no errors and I can inspect the data saved to local storage using the resources tab in dev tools. I would suggest checking you're using all the latest versions of the various libraries in your local build.
这篇关于骨干localStorage的:无法读取属性未定义'递延'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!