/backbone-localStorage-urlShortener/app/scripts/collections/url-collection.js
JavaScript | 18 lines | 11 code | 6 blank | 1 comment | 0 complexity | 22cbd2f7125ebf614596b51c28f1d2cb MD5 | raw file
Possible License(s): Apache-2.0, MIT
- /*global backboneUrlShortener, Backbone*/
- backboneUrlShortener.Collections.UrlCollection = Backbone.Collection.extend({
- cache: new Backbone.LocalStorage('urls'),
- model: backboneUrlShortener.Models.UrlModel,
- initialize: function () {
- this.on('change', this.cacheUrl, this);
- this.add(this.cache.findAll());
- },
- cacheUrl: function (model) {
- this.cache.create(model);
- }
- });