jquery - How can I dynamically add to a JavaScript object similar to JavaScripts array push function? -


how can add data.data.trek.places object. example, if user triggers event want add object , able iterate on again, i'm not sure how it. couldn't find similar push function arrays. app sits on top of backbone, maybe there underscore function this?

i want do:

data.data.trek.places.push({                             "url" : "/attraction/mauna-kea-summit/19",                             "img_src" : "http://trekeffect.images.user_images.s3.amazonaws.com/4_36.jpg",                             "title" : "mauna kea summit",                             "time_going" : "1368787333",                             "time_going_hour" : 1,                             "time_going_minutes" : 55,                             "duration" : "3600",                             "id" : 19,                             "type" : "attraction",                             "city_id" : 6                            }); 

the json have coming original ajax below:

{   "data":{   "trek":{      "places" : [         {            "url" : "/attraction/mauna-kea-summit/19",            "img_src" : "http://trekeffect.images.user_images.s3.amazonaws.com/4_36.jpg",            "title" : "mauna kea summit",            "time_going" : "1368687333",            "time_going_hour" : 1,            "time_going_minutes" : 55,            "duration" : "3600",            "id" : 19,            "type" : "attraction",            "city_id" : 6         },         {            "url" : "/attraction/mauna-kea-resort-golf-course/20",            "img_src" : "http://trekeffect.images.user_images.s3.amazonaws.com/4_41.jpg",            "title" : "mauna kea resort golf course",            "time_going" : "1368704533",            "time_going_hour" : 6,            "time_going_minutes" : 42,            "duration" : "5400",            "id" : 20,            "type" : "attraction",            "city_id" : 6         }      ]   } 

} }

data.data.trek.places is array.
it's other array, except happens referenced property of object.

you can use other array.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -