ember.js - Nested json object in ember -


the following link works till positions when add object(company) not displaying anything.

refer fiddle

app.jsonobject = {     id: 1812,     name: 'brokerage account',     positions: [         {             symbol: 'aapl',             quantity: '300',             company:[                 {                     no: '1',                     name: 'test'                 }                 ]         },         {             symbol: 'goog',             quantity: '500',             company:[                 {                     no: '2',                     name: 'test123'                 }                 ]         }     ] }; 

the reason why not working because down json structure have plain javascript objects. ember aware of changes , bindings work need use framework's methods ember.object.create (like app.account), objectat(0), pushobject() etc. create data structure. way bindings , else work expected.

edit in response last comment

a simplistic straight forward way change code this:

app.account = ember.object.create({   id: 1812,   name: 'brokerage account',   positions: ember.a([     ember.object.create({       symbol: 'aapl',       quantity: '300',       company: ember.a([         ember.object.create({           no: '1',           name: 'test'         })       ])     }),     ember.object.create({       symbol: 'goog',       quantity: '500',       company: ember.a([         ember.object.create({           no: '2',           name: 'test123'         })       ])     })   ]) }); 

so can later use framework methods , stuff like:

app.get('account').get('positions').pushobject(ember.object.create({symbol: 'msft', quantity: 200})); 

or

app.get('account').get('positions').objectat(0).setproperties({'quantity': 500}); 

and here updated fiddle: http://jsfiddle.net/wkgkj/3/

note, fiddle working please don't quote me on approach since it's not preferred ember way of building ember applications, made work backup answer :) worth mentioning in fiddle using 'ember 0.9.4which outdated since version1.0.0-rc.6.1` around.

hope helps.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -