ember-data

Ember query params not sending params in the request

女生的网名这么多〃 提交于 2019-12-23 00:25:10
问题 The query-params-new flag set to true. Using latest ember and ember data. Ember: 1.6.0-beta.1+canary.b5b90241 ember.js and Ember Data : 1.0.0-beta.7+canary.b45e23ba Application Adapter is set to this: export default DS.RESTAdapter.extend({ host: 'http://example.com', namespace: 'api/v2', headers: { "ClientId": "a-key", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Headers": "X-Requested-With" } }); The locations route looks like this: export default Ember.Route.extend({ model:

Ember model lifecycle, and reverting to original state

懵懂的女人 提交于 2019-12-22 18:29:09
问题 I'm struggling to understand everything about the ember model lifecycle. I have created this jsfiddle to illustrate my problem. When clicking on one of the entries in the list, editing a value, and clicking the versions link to go back to the list, I get the following error: Uncaught Error: Attempted to handle event loadedData on while in state rootState.loaded.updated.uncommitted. Called with {} What is causing this? I get that the object state is now dirty, but how can I force a refresh of

Action Cables, nested JSON attributes and JSONAPI

喜夏-厌秋 提交于 2019-12-22 15:54:31
问题 I have a fairly specific problem that I was hoping one of you really intelligent folk might know a solution for (or even a workaround at this stage) Specifically, I'm dealing with action cables, nested JSON, and the JSONAPI . I have an asset model, which has some attributes like name , desc etc. but it also has an attribute called state which is a complex nested JSON object. // app/models/asset.js export default DS.Model.extend({ // Attributes name: DS.attr('string'), desc: DS.attr('string'),

Ember store.push with hasMany doesn't update template?

佐手、 提交于 2019-12-22 14:18:56
问题 Assuming the following models : App.User = DS.Model.extend( email: DS.attr('string') session_users: DS.hasMany('sessionUser') ) App.SessionUser = DS.Model.extend( user: DS.belongsTo('user') state: DS.attr('string') session: DS.belongsTo('session') ) App.Session = DS.Model.extend( title: DS.attr('string') session_users: DS.hasMany('sessionUser') ) The route session_route.js.coffee : App.SessionRoute = Ember.Route.extend( model: (params) -> this.store.find('session', params.id) ) And the

Ember store.push with hasMany doesn't update template?

拥有回忆 提交于 2019-12-22 14:17:07
问题 Assuming the following models : App.User = DS.Model.extend( email: DS.attr('string') session_users: DS.hasMany('sessionUser') ) App.SessionUser = DS.Model.extend( user: DS.belongsTo('user') state: DS.attr('string') session: DS.belongsTo('session') ) App.Session = DS.Model.extend( title: DS.attr('string') session_users: DS.hasMany('sessionUser') ) The route session_route.js.coffee : App.SessionRoute = Ember.Route.extend( model: (params) -> this.store.find('session', params.id) ) And the

Ember Data: Why hasMany and belongsTo

柔情痞子 提交于 2019-12-22 13:53:18
问题 I'm wondering why I have to define hasMany and belongsTo in two related data sets? It seems redundant as all necessary information is in one of the arrays already and it is difficult to keep both synchronized. It also doesn't reflect the tables in an sql database where there is only one foreign key in one table in an one-to-many relationship. 回答1: Because relationships can go one or two ways. In your SQL example, a foreign key in one table only places a restraint on that table, NOT the table

Ember Data Save method, Create vs update

只愿长相守 提交于 2019-12-22 11:57:47
问题 I can't figure out how Ember determines if it should update or create a record. I would assume its based on the ID or on the Store entry, but it seems to be something else. The code example clarifies: // this returns the user without making an api call currentUser.get('store').find('user_detail', '49') // this returns 49 currentUser.get('id') // this returns true currentUser.get('store').hasRecordForId('user_detail', 49) // this issues a create to api/userDetails instead // of updating /api

Ember Data Save method, Create vs update

爱⌒轻易说出口 提交于 2019-12-22 11:57:11
问题 I can't figure out how Ember determines if it should update or create a record. I would assume its based on the ID or on the Store entry, but it seems to be something else. The code example clarifies: // this returns the user without making an api call currentUser.get('store').find('user_detail', '49') // this returns 49 currentUser.get('id') // this returns true currentUser.get('store').hasRecordForId('user_detail', 49) // this issues a create to api/userDetails instead // of updating /api

Ember Data: A data hash was loaded … but no primary key 'undefined' was provided

拈花ヽ惹草 提交于 2019-12-22 11:15:56
问题 I'm trying to use Ember Data to load a model. The AJAX call to fetch the model seems to be successful but I get the following Uncaught Error: assertion failed: A data hash was loaded for a model of type App.Account but no primary key 'undefined' was provided. In ember-data.js:1128 it seems to be deferencing undefined for the primaryKey and not defaulting to 'id' when a model doesn't specify a primaryKey. But I've also tried being explicit with the primaryKey to no effect. For completeness,

filter paginate pass parameters to asynchronous ember data relationship requests

泪湿孤枕 提交于 2019-12-22 08:55:48
问题 I want to implement paging/filtering on ember data asynchronously. This is my author model: export default DS.Model.extend({ user: DS.belongsTo('user'), articles: DS.hasMany('article', { async: true }), name: DS.attr('string'), email: DS.attr('string') }); route: export default Ember.Route.extend({ model: function(params) { return this.store.find('author', params.author_id); } }); controller: export default Ember.ObjectController.extend({ popularArticles: function() { return this.get('model