I am using Backbone.LocalStorage : http://jsfiddle.net/jiewmeng/grhz9/3/
Backbone.LocalStorage
$(function() { console.log(Backbone.LocalStorage); // undefined!! var Todo = Backbone.Model.extend({}); var Todos = Backbone.Collection.extend({ model: Todo, localStorage: new Backbone.LocalStorage("todos") }); });β
The first console.log() gives undefined . Then in the line localStorage: ...
console.log()
undefined
localStorage: ...
Uncaught TypeError: undefined is not a function
Backbone.LocalStorage is expected to be undefined , but why?
Downloadable backbone.localStorage-min.js :
backbone.localStorage-min.js
http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.0/backbone.localStorage-min.js
it looks like it is deprecated and it does not define Backbone.LocalStorage at all. The version of backbone.localStorage-min.js that you use defines window.Store , not Backbone.LocalStorage . If you switch to this ( http://jsfiddle.net/ambiguous/grhz9/5/ ):
window.Store
var Todos = Backbone.Collection.extend({ model: Todo, localStorage: new Store("todos") });
then you can complete your Todos collection. I donβt know how well everything will work when you are actually trying to use it. "Sun Aug 14 2011 09:53:55 -0400" pretty much forever back in internet time, so the version is pretty antique.
Todos
If you upgrade to the latest version from Github:
https://raw.github.com/jeromegn/Backbone.localStorage/master/backbone.localStorage-min.js
you will see that there are several differences in JavaScript, and everything will start working when you use new Backbone.LocalStorage('todos') :
new Backbone.LocalStorage('todos')
http://jsfiddle.net/ambiguous/grhz9/4/
Another answer is correct - 1.0 is out of date.
I updated backbone.localstorage to the latest version:
http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.1.0/backbone.localStorage-min.js (production)
http://cdnjs.cloudflare.com/ajax/libs/backbone-localstorage.js/1.1.0/backbone.localStorage.js (dev)
Hope this helps!
Source: https://habr.com/ru/post/917273/More articles:Matching many in many ways with the foreign key guide - c #Heroku: push reject - failed to set gems through a bundle - ruby-on-railsHow can I read the output of a child process? - cMySQL Query for counting the number of databases a user owns? - mysqlWhy doesn't Capistrano set gemstones with a bunch? - ruby-on-railsHow to convert structured text to data columns in R? - rSending a large file using HttpWebRequest, increasing / decreasing the buffer as needed - httpExtract statistics from google play - javaJava string [] partial copying - javaEclipse error: selection must be WSDL - javaAll Articles