ember.js

How do I get Rails to generate JSON in the correct format for ember.js?

北城余情 提交于 2019-12-22 06:11:40
问题 In the Ember guide on models http://emberjs.com/guides/models/the-rest-adapter/#toc_relationships I see that associations should be specified as an array of ids: { "post": { "comments": [1, 2, 3] } } I'm having trouble working out how to generate the array of ids in the rails controller. While I can :include the associated models, they are included as an array of hashes: {"name":"Jane's Place","rooms":[{"id":1},{"id":2},{"id":3}]} Any ideas on how one would get the array form? 回答1: Ember

How do I get Rails to generate JSON in the correct format for ember.js?

↘锁芯ラ 提交于 2019-12-22 06:11:09
问题 In the Ember guide on models http://emberjs.com/guides/models/the-rest-adapter/#toc_relationships I see that associations should be specified as an array of ids: { "post": { "comments": [1, 2, 3] } } I'm having trouble working out how to generate the array of ids in the rails controller. While I can :include the associated models, they are included as an array of hashes: {"name":"Jane's Place","rooms":[{"id":1},{"id":2},{"id":3}]} Any ideas on how one would get the array form? 回答1: Ember

Emberjs - Disable and Enable TextField

荒凉一梦 提交于 2019-12-22 06:02:30
问题 So I've recently found the disabled attribute in the Em.TextField, however I can't seem to re-enable the TextField after I've extended it with the disabled property set to true. var app = Em.Application.create(); app.randomObj = Em.Object.create({ temp: null }); app.textField = Em.TextField.extend({ valueBinding: 'app.randomObj.temp', disabled: true }); How do I remove the disabled property with Ember? 回答1: There are some issues with your sample code, I'll adress each one and hope I can clear

Emberjs - Disable and Enable TextField

自古美人都是妖i 提交于 2019-12-22 06:02:24
问题 So I've recently found the disabled attribute in the Em.TextField, however I can't seem to re-enable the TextField after I've extended it with the disabled property set to true. var app = Em.Application.create(); app.randomObj = Em.Object.create({ temp: null }); app.textField = Em.TextField.extend({ valueBinding: 'app.randomObj.temp', disabled: true }); How do I remove the disabled property with Ember? 回答1: There are some issues with your sample code, I'll adress each one and hope I can clear

Ember.js - Call parent model hook to load data for child

陌路散爱 提交于 2019-12-22 06:01:29
问题 I have a master/detail view in Ember. If i am calling the detail page directly, the model hook of the detail page needs the model(data) from the parent(master). The detail model hook is called - whats the proper way to get/call the model so the modelFor function in the detail hook works. Router: App.Router.map(function(){ this.resource('index', { path: '/' } ); this.resource('devices', { path: '/devices'}, function() { this.resource('device', { path: ':imei'}); }); }); Master Route: App

Ember.js - Call parent model hook to load data for child

筅森魡賤 提交于 2019-12-22 06:01:05
问题 I have a master/detail view in Ember. If i am calling the detail page directly, the model hook of the detail page needs the model(data) from the parent(master). The detail model hook is called - whats the proper way to get/call the model so the modelFor function in the detail hook works. Router: App.Router.map(function(){ this.resource('index', { path: '/' } ); this.resource('devices', { path: '/devices'}, function() { this.resource('device', { path: ':imei'}); }); }); Master Route: App

Read object properties in handlebars template

北城以北 提交于 2019-12-22 05:53:21
问题 Is there a some way to read object properties using handlebars or ember helpers? {{#each object in objects}} <tr> {{#each key in keys}} {{!- doesn't work, because object[key] isn't valid syntax I guess --}} <td>{{object[key]}}</td> {{/each}} </tr> {{/each}} I know that I can read properties like so {{object.someProperty}} , however in my case the list of properties which needs to be read is passed to a component as an argument (in my example it is called keys ). Maybe this function already

How do I pass in more than one parameter to the onChange action for the select element in Ember2.3

情到浓时终转凉″ 提交于 2019-12-22 05:39:17
问题 I have a select element within a loop, and the action I want to be triggered needs to have two parameters: the selected option of the select element and the item we are looping with. My code looks like so: {{#each loopItems as |loopItem|}} <select onChange={{action 'fireThis' loopItem target.value }}> {{#each loopItem.subItems as |subItem|}} <option value={{subItem.id}}>{{subItem.value}}</option> {{/each}} </select> {{/each}} And my fireThis action is like so: fireThis:function(loopItem,

ember.js widgets

泄露秘密 提交于 2019-12-22 04:41:12
问题 I know that ember js is good for single page apps and it appears that you can localize ember js app to a single dom container rather than the whole page, so I'm wondering if ember js would be a good fit for advanced widget creation, not just a slightly fancy drop down or anything but a more complex widget which may deal with its own restful resource etc. Or is using ember.js in this way overkill? If it is suitable for widgets, would it be possible without having to recode the widgets to use

ember tests passing in chrome, not in phantomjs

穿精又带淫゛_ 提交于 2019-12-22 04:34:08
问题 I have tests for an addon which pass in chrome, but fail in phantomjs. It seems to be a problem similar to this question. However, I tried the solution there and it didn't work for me. The code is all available in the public repo linked above. The failures are exhibited in the failing travis build on github. Any ideas on how to diagnose better and fix? EDIT -- actual error message Died on test #1 at http://localhost:7357/assets/test-support.js:3062 at test (http://localhost:7357/assets/test