backbone.js - Backbone read JSON item and save to model -
Hello I am new to backbone, but I have to solve a problem.
There is a working webapp - Online shop. A JSON file is received from the / lampy / api / filter on CartView browser.
I need to save it in a model some way because I want something from that to me?
How should I do this?
Thanks in advance.
>Assume that your JSON object looks:
{item1: 'some strings', Item 2: 'another string', item 3: 'and second'} when you say:
save it in some way in the model
I assume that you instantiate a model with the values of your JSN object. To do this you can just do this:
var myModel = new Backbone.Model (yourJsonObject) This is just a plain without a URL The BABON model will be so you will not be able to interact with the server with it, but as you said you need some of its value so that you can use it:
myModel Get ('item1') // 'returns some string'
Comments
Post a Comment