javascript - Adding Models to Backbone.js Collection Silently Fails -
i implementing blog engine learning exercise new job. have backbone.js collection class called bloglist composed of blogmodel objects (a blogmodel single post blog). have masterbloglist keeps blog posts in memory lifetime of application (i realize not realistic design, part of spec).
i have chosen use masterbloglist hold canonical state of application. new posts, edits, etc. persisted database (mongodb) masterbloglist. when want display subset of posts in masterbloglist, copy them new bloglist instance , narrow new instance down based on search criteria. again, realize might not best design (cloning blogmodels , bloglists), i've got , i'd prefer not rework it.
the problem copying 1 bloglist not working. when source list non-empty, destination list ends being empty. have tried debug every way no luck. here relevant portion of bloglist source code:
// bloglist $ (function () { app.bloglist = backbone.collection.extend ({ model : app.blogmodel, url : '/blog-entries', comparator : function (a) { return -(new date (a.get ('date'))); }, populatefrommemory : function (sourcelist) { // this.reset (); var self = this; sourcelist.each (function (postmodel) { self.add(postmodel); }); var foo = new app.blogmodel(); this.add(foo); },
(continued...)
even last bit regarding foo not working. i've tried adding clone() of postmodel , new app.blogmodel(postmodel.tojson()).
any extremely appreciated!
sorry have bothered :<, got working. code work written above. problem search criteria filtering out of posts, wasn't seeing anything. end of long day! tried me...
Comments
Post a Comment