Questions tagged [backbone-local-storage]

A localStorage adapter for Backbone.js

A localStorage adapter for Backbone.js

An adapter that replaces Backbone.sync to save to window.localStorage instead of to the server.

Github: https://github.com/jeromegn/Backbone.localStorage

Docs: http://backbonejs.org/docs/backbone.localStorage.html

30 questions
17
votes
2 answers

Saving a model in local storage

I'm using Jerome's localStorage adapter with Backbone and it works great for collections. But, now I have a single model that I need to save. So in my model I set: localStorage: new Store("msg") I then do my saves and fetch. My problem is that…
6
votes
2 answers

Backbone Local Storage "undefined is not a function"

I am using Backbone.LocalStorage: http://jsfiddle.net/jiewmeng/grhz9/3/ $(function() { console.log(Backbone.LocalStorage); // undefined!! var Todo = Backbone.Model.extend({}); var Todos = Backbone.Collection.extend({ model:…
Jiew Meng
  • 74,635
  • 166
  • 442
  • 756
2
votes
1 answer

.fetch() collection backbone.js doesn't work

I want to call API URL to get data, and pass it to a view, but encounter an error when using fetch property: Uncaught TypeError: Cannot read property 'localStorage' of undefined at G.d.Backbone.sync (backbone.localStorage-min.js:8) at…
2
votes
1 answer

Backbone collection doesn't fetch by ajax if has set localStorage object

I want to use backbone.localStorage.js plugin in my app and here is a code sample: Module.Vehicles = Backbone.Collection.extend({ initialize : function(options) { this.customerId = options.customerId; }, url :…
1
vote
1 answer

Backbone: synchronizing Models and LocalStorage

I've extended a model A and a collection of As as follows: define(['underscore', 'backbone', 'backbone.localStorage'], function(_, Backbone) { var A = Backbone.Model.extend({ initialize: function() { } }); var…
acimutal
  • 1,935
  • 2
  • 14
  • 22
1
vote
1 answer

Backbone local storage

I'm new to backbone, I'm following a tutorial and I'm trying to use local storage as a database, but I wasn't able to find an article that explains about how to use them together. This is the code: $(function() { window.app = { Models: {}, …
1
vote
1 answer

Make Backbone.js items within localStorage unique?

I have a dupe check within my collection, where I'm overriding the add function and it seems to work until a page refresh. Duplicates are blocked with an alert saying "You've already added this item to the todo list!" but it seems like when the…
Alex Ung
  • 69
  • 2
  • 10
1
vote
1 answer

using backbone localStorage on a nested Collection

I'm trying to implement nested Collections exactly like the example I found here: https://stackoverflow.com/a/17453870/295133 The only difference being is that I'm trying to store the data locally using the localStorage plugin. Here, my Lists would…
Adam
  • 8,349
  • 16
  • 64
  • 126
1
vote
1 answer

Destroy all models in Backbone collection (persisted in local storage)

How do I delete all models in my collection (persisted in local storage)? The models are fetched from local storage - I want the models to be destroyed both at the client and also in local storage. // Model + Collection App.Models.Task =…
nodesto
  • 445
  • 2
  • 7
  • 21
1
vote
0 answers

Backbone - Syncing simultaneously with Server and LocalStorage

Here is a problem that I am working on: There is a view and it has a collection. I want to update the UI when the user interaction results in a model being added to the collection. The UI update should be instantaneous. If the web app is open in…
GunnerFan
  • 2,099
  • 2
  • 17
  • 32
1
vote
0 answers

Retrieve an item from Backbone with ID in URL (independent of collection / model)

I am looking to retrieve a specific piece of data from Backbone (I'm using the localStorage adapter, not a server). I can see the ID of the items by looking at inspector. I want a way to click on any item in any view, regardless of the collection it…
1
vote
1 answer

LocalStorage Backbone.js

Can anybody tell me is it possible to get and set values in localStorage Here is my code var TodoApp = {}; TodoApp.model = Backbone.Model.extend({ defaults: { title : '', done : false } }); TodoApp.list =…
John Thomas
  • 171
  • 1
  • 3
  • 16
1
vote
0 answers

Collection renders fine when loaded from remote Url, but not when loaded from localStorage (initialize vs. onRender)

I'm using a layout's 'initialize' method to instantiate a collection, fetch() data from a url on that collection, and then instantiate a new collectionView passing through the collection with it's fetched data. The collectionView later gets 'shown'…
Jarred
  • 11
  • 1
1
vote
0 answers

Fetching a model using Backbone.LocalStorage returns success even though item does not exist

If I haven't saved my Backbone Model to local storage (via Backbone.LocalStorage adapter) using the save() method, how come fetch() returns a success callback? Shouldn't it return an error or some other indication that the model is not in fact in…
Gabe M
  • 61
  • 2
  • 7
0
votes
1 answer

How to store data in localStorage using Backbone.js

I'm new with backbone.js. How can I store data in my localstorage and retrieve them? I am using jeromegn's Backbone.localStorage but why can't I add or save it into the localstorage? Here's my collection: var Cases = Backbone.Collection.extend({ …
1
2