javascript - BackboneJS Iterate complex model -


i have backbonejs composite model has 2 attributes;

"myattr1": new myobj1(model.myattr1), "mycollectionattr": new myobj2(model.mycollectionattr) 

myobj2 looks like

"attr1" : new base1( ), "attr2" : new base2( ) 

now want set inner level attribute (i.e. attribute of base1)...so iterate , say;

self.model.get("mycollectionattr").each(function(model) {     model.get("attr1").set('basemodel1attr','y'); }); 

so base1 , base2 model has attributes basemodel1attr , basemodel2attr

while model.get("attr1") returns me list of attributes. cannot use .set() on it.

what correct way of doing set on inner attribute ?

if understand correctly want iterate through models of collection , set 1 specific attribute of model this

$.each(collection.models, function(i, model){     model.set('item','new value'); } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -