backbone.js-collections

Bubbling events in nested Backbone (Marionette) Models / Collections

爱⌒轻易说出口 提交于 2019-11-28 02:19:59
We have a large Marionette App, that uses Backbone.trackit to monitor unsaved changes in our Models. We now have some nested models, in fact we have a Model, with a Collection of Models, that contain a Collection of Models. trackit doesn't support the top level model being marked as 'dirty' when the child models change - due to backbone not bubbling these change events. I know we could manually monitor these change events, but Im looking for a generic solution. Has anyone had any experience of the following libs or any other solutions for this? backbone-deep-model Backbone Associations events

Saving jQuery UI Sortable's order to Backbone.js Collection

我们两清 提交于 2019-11-27 16:48:40
I have a Backbone.js collection that I would like to be able to sort using jQuery UI's Sortable. Nothing fancy, I just have a list that I would like to be able to sort. The problem is that I'm not sure how to get the current order of items after being sorted and communicate that to the collection. Sortable can serialize itself, but that won't give me the model data I need to give to the collection. Ideally, I'd like to be able to just get an array of the current order of the models in the collection and use the reset method for the collection, but I'm not sure how to get the current order.

Filter backbone collection by attribute value

倖福魔咒の 提交于 2019-11-27 09:40:41
问题 I have a defined model and a collection: var Box = Backbone.Model.extend({ defaults: { x: 0, y: 0, w: 1, h: 1, color: "black" } }); var Boxes = Backbone.Collection.extend({ model: Box }); When the collection is populated with the models, I need a new Boxes collection made out of Box models that have a specific color attribute contained in the complete collection, I do it this way: var sorted = boxes.groupBy(function(box) { return box.get("color"); }); var red_boxes = _.first(_.values(_.pick

The collection nested inside firebase collection's model doesn't have add function

本小妞迷上赌 提交于 2019-11-27 05:40:45
In my application, I am trying to use Firebase to store the real time data based on backbone framework. The problem goes like this: I have a sub level model and collection, which are both general backbone model and collection. var Todo = Backbone.Model.extend({ defaults: { title: "New Todo", completed : true } }); var Todocollection = Backbone.Collection.extend({ model: Todo, initialize: function() { console.log("creating a todo collection..."); }, }); And then there is a high level model, which contains the sublevel collection as an attribute. var Daymodel = Backbone.Model.extend({ defaults :

Best practice for saving an entire collection?

我与影子孤独终老i 提交于 2019-11-27 05:27:57
问题 Say that I have a Collection and I've made changes to many of its Models. What's the best way to save all of the changes using a single HTTP request? 回答1: Usually REST backends handle single instance creation/update. You would need to change that to accept an array of objects. That said, on the client side, you would need to go directly to the Backbone.sync function Backbone.sync = function(method, model, options) In this case your model should be an array of model. The method should be

Bubbling events in nested Backbone (Marionette) Models / Collections

只谈情不闲聊 提交于 2019-11-26 23:39:59
问题 We have a large Marionette App, that uses Backbone.trackit to monitor unsaved changes in our Models. We now have some nested models, in fact we have a Model, with a Collection of Models, that contain a Collection of Models. trackit doesn't support the top level model being marked as 'dirty' when the child models change - due to backbone not bubbling these change events. I know we could manually monitor these change events, but Im looking for a generic solution. Has anyone had any experience

Saving jQuery UI Sortable's order to Backbone.js Collection

泪湿孤枕 提交于 2019-11-26 22:29:10
问题 I have a Backbone.js collection that I would like to be able to sort using jQuery UI's Sortable. Nothing fancy, I just have a list that I would like to be able to sort. The problem is that I'm not sure how to get the current order of items after being sorted and communicate that to the collection. Sortable can serialize itself, but that won't give me the model data I need to give to the collection. Ideally, I'd like to be able to just get an array of the current order of the models in the

The collection nested inside firebase collection's model doesn't have add function

白昼怎懂夜的黑 提交于 2019-11-26 11:40:03
问题 In my application, I am trying to use Firebase to store the real time data based on backbone framework. The problem goes like this: I have a sub level model and collection, which are both general backbone model and collection. var Todo = Backbone.Model.extend({ defaults: { title: \"New Todo\", completed : true } }); var Todocollection = Backbone.Collection.extend({ model: Todo, initialize: function() { console.log(\"creating a todo collection...\"); }, }); And then there is a high level model