How to bind content with JSON in Ember.js -



How to bind content with JSON in Ember.js -

all examples using fixed info source in arraycontroller.content, while using dynamic info source generated anther web service , returns json, won't create object declared in ember, here code sample:

et.appyear = ember.object.extend({ text:null, value:null }); et.emailtypes = ember.object.extend(); et.appyearcontroller = ember.arraycontroller.create({ content: [], loadyears: function (year) { if (year != null) { (var = -5; < 5; i++) { this.pushobject({ text: year + i, value: year + }); //.appyear.create({ text: year + i, value: year + }); } } } }); et.selectedappyearcontroller = ember.object.create({ selectedappyear: '2011', alertchange: function(){ alert("selected app year " + this.get('selectedappyear')); }.observes('selectedappyear'), ischanged: function () { if (this.appyear != null) { this.set('selection',this.get('content')); //loadetbyappyearettypeid(this.selectedappyear, et.selectedemailtypescontroller.emailtype.email_template_type_id); } } .observes('selectedappyear'), appyear: function() { var ay = et.appyearcontroller.findproperty('text',this.get('selectedappyear')); homecoming ay; }.property('selectedappyear') });

as can see, phone call et.appyearcontroller.loadyears(json) in ajax post back, create content using this.pushobject, not et.appyear object schema, while phone call et.selectedappyearcontroller.selectedappyear, returns undefined object, , returns object {text:xx,value,xx} schema. that's why selectionbinding won't work in case.

so what's typical solution import json elements defined object , set content?!

take @ ember-data library, made use-case , related use-cases:

https://github.com/emberjs/data

ember.js

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -