I've got the following JSON provided from a server. With this, I want to create a model with a nested model. I am unsure of which is the way to achieve this. //json [{ name : "example", layout : { x : 100, y : 10...
My models already have a defaults hash. When parts of the view/page are reset, I wish to reset the models back to their original defaults. Currently, I explicitly set each attribute to its default value. Is there anything built in or a JavaScript/Un...
I bind on the change event of my backbone models like this. this.model.on( "change", this.render, this ); Sometimes I want to fetch the latest version of the model and forcibly render the view. So I do this this.model.fetch(); Unfortun...
Here's the goal: I have a parent model. It is in a collection called parents. In a parent is a collection of children. So, when I instantiate the parents collection, I get the parent models, each with the collection of children in them. I've...
tl;dr How to use backbone.stickit with a html form to change an existing model fetched from the server and only PATCH the changed attributes (changed by user input within the html form) to the server? /tl;dr I'm using backbone.stickit in a bac...
I have a simple question about Backbone.js' get and set functions. 1) With the code below, how can I 'get' or 'set' obj1.myAttribute1 directly? Another question: 2) In the Model, aside from the defaults object, where can/should...
I have an object that's also saved in the server and I'm creating a Backbone model from that object. But when I save the model, it's doing a PUT request, which is not what I want. How to tell Backbone that the data is already in the ser...
How to prevent parse function for model in collection fetching? $(function() { var Task = Backbone.Model.extend({ url : function() { return this.urlRoot + this.id; }, urlRoot: 'index.php?c=light&am...
Here is what I am trying to understand. Often times I find myself writing backbone like this: var CallModel = Backbone.Model.extend({ }); var CallsCollection = Backbone.Collection.extend({ model: CallModel, url: 'url/to/external/json...
When developing Backbone applications, I often find myself instantiating models in views when dealing with nested data. Here's some example data: { name: Alfred, age 27, skills: [ { name: 'Web development', level: &...
©2020 All rights reserved.