I am using backbone localstorage plugin however, it is giving me following error.
Uncaught TypeError: Backbone.LocalStorage is not a function
I am using it in following way in my collection
var TodoList = Backbone.Collection.extend({
model: TodoModel,
localStorage: new Backbone.LocalStorage('todos-backbone')
});
How can I solve this problem?
UPDATE
I import them in index.html
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/backbone/node_modules/underscore/underscore-min.js"></script>
<script src="node_modules/backbone/backbone-min.js"></script>
<script src="node_modules/backbone-localstorage/backbone-localStorage.js"></script>
<script src="js/models/todo.js"></script>
<script src="js/collections/todos.js"></script>
<script src="js/views/todos.js"></script>
<script src="js/views/app.js"></script>
<!-- <script src="js/routers/router.js"></script> -->
<script src="js/app.js"></script>
I think you are confusing https://github.com/jeromegn/Backbone.localStorage and https://github.com/robmoorman/backbone-localstorage. Backbone.LocalStorage
is a function only in the former while the one you have included is used like this:
var TodoList = Backbone.Collection.extend({
model: TodoModel,
localStorage: true
});