PageRenderTime 53ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/backbone-localStorage-urlShortener/app/scripts/collections/url-collection.js

https://github.com/stephenplusplus/yeoman-examples
JavaScript | 18 lines | 11 code | 6 blank | 1 comment | 0 complexity | 22cbd2f7125ebf614596b51c28f1d2cb MD5 | raw file
Possible License(s): Apache-2.0, MIT
  1. /*global backboneUrlShortener, Backbone*/
  2. backboneUrlShortener.Collections.UrlCollection = Backbone.Collection.extend({
  3. cache: new Backbone.LocalStorage('urls'),
  4. model: backboneUrlShortener.Models.UrlModel,
  5. initialize: function () {
  6. this.on('change', this.cacheUrl, this);
  7. this.add(this.cache.findAll());
  8. },
  9. cacheUrl: function (model) {
  10. this.cache.create(model);
  11. }
  12. });