ember.js - Using this.store.query() in a computed property -


i've build custom dropdown element , i'm trying use display couple of things:

{{drop-down items=types selectionchanged="typechanged"}}  {{drop-down items=meters selectionchanged="meterchanged"}} 

in controller i'm setting values follows:

types: [   { value: "latest", name: "latest widget" },   { value: "max", name: "maximum widget" },   { value: "average", name: "average widget" }, ],  meters: ember.computed(function() {   var meters = this.store.query('meter', { account_id: 2 });   return meters; }), 

the values both appearing correctly:

<select id="ember826" class="ember-view form-control">   <option value="">please select widget type...</option>   <option value="latest">latest widget</option>   ... </select>  <select id="ember849" class="ember-view form-control">   <option value="2">meter 1</option> </select> 

my drop-down component uses following work out selected value:

change: function(event) {   var items = this.get('items');   var index = event.target.selectedindex;   var selected = items ? items[index - 1] : null;   console.log(selected); // error occurs here   this.sendaction('selectionchanged', selected); } 

now works fine 'types' 'meters', selected "undefined".

i added console.log(json.stringify(items)); before line and, meters change, gave me following error:

uncaught typeerror: converting circular structure json

if add {{log types}} , {{log meters}} template, following, may shed light on it:

types:

result of {{log types}}

meters:

result of {{log meters}}

i notice latter has wrapped in couple of layers of 'content' keys maybe promise isn't being resolved properly?

edit

if use this.store.query in route , {{log}} model it's wrapped in single 'content' key, ember can correctly interpret. there reason why doing in controller should create one?

use objectat access items ember collection.

change: function(event) {   var items = this.get('items');   var index = event.target.selectedindex;   var selected = items ? items.objectat(index - 1) : null;   console.log(selected); // error occurs here   this.sendaction('selectionchanged', selected); } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -