ember-data

How to specify async belongsTo/hasMany relationships in emberfire/emder-data?

北城以北 提交于 2019-12-20 07:22:22
问题 I am very new at Ember/ED/EmberFire so apologies if this is a trivial question. I am able to save records to Firebase but I am unable to specify relationships to those records in my controller. I am using DEBUG: Ember : 1.10.0 DEBUG: Ember Data : 1.0.0-beta.12 DEBUG: Firebase : 2.2.3 DEBUG: EmberFire : 1.4.3 DEBUG: jQuery : 1.11.2 I have a model as such: var Patient = DS.Model.extend({ lastName: DS.attr('string'), firstName: DS.attr('string'), encounters: DS.hasMany('encounter', {async: true}

Error Attempted to handle event `loadedData` : Object not updated after deleteRecord

为君一笑 提交于 2019-12-20 06:48:19
问题 Using the last version of ember-js and ember-data, I got an issue when deleting a record. My route : App.ListContactsRoute = Em.Route.extend({ model: function() { App.Contact.find(); }, setupController: function(controller, model) { controller.set('contacts', model); } }); App.EditContactRoute = Em.Route.extend({ setupController: function(controller, model) { this.transaction = controller.get('store').transaction(); this.transaction.add(model); controller.set('content', model); controller.set

How to observe for changes in the Ember data store?

丶灬走出姿态 提交于 2019-12-20 06:37:23
问题 I created this simple JsBin to demonstrate what I'm after. JSBIN I have some Fixture data and each item in it has a boolean property called isFavourite. The indexRoute just displays all the available data along with a second section that displays the items that are favourites. Each item also has a class binding to this isFavourite property. If it's a favourite, it'll have red text. There is a second route called dashboard which only displays a subset of the data from the store. There is also

Ember data: save loses belongsTo relationship

拜拜、爱过 提交于 2019-12-20 05:59:11
问题 I have the following problem: A form with a select field for selecting the category of a post. Let's say the post has category 100. In Ember inspector, this is shown as follows: category: <App.Category:ember708:100> When I save the post (via Ember Data 1.0.0 beta 2), the category suddenly changes to: category: 100 And the value is no longer selected in the select list. It is cleared. Code to save: post.save().then( function () { alert("Save OK"); } ) Any idea in which direction I need to

How to refresh entity using ember data

萝らか妹 提交于 2019-12-19 20:38:22
问题 In my aplication I recived with websockects info about with objects are changed and ember data should reload them. How can I force emberdata to update already loaded record? How can I force emberdata to get know from server that some records are already delted? 回答1: The only way I could find to achieve something like this is to trigger manually App.store.loadMany(data) with the json (if you have it), or performing a App.store.findQuery(App.Model, {}) , which will invalidate your cache. I

How to refresh entity using ember data

让人想犯罪 __ 提交于 2019-12-19 20:37:02
问题 In my aplication I recived with websockects info about with objects are changed and ember data should reload them. How can I force emberdata to update already loaded record? How can I force emberdata to get know from server that some records are already delted? 回答1: The only way I could find to achieve something like this is to trigger manually App.store.loadMany(data) with the json (if you have it), or performing a App.store.findQuery(App.Model, {}) , which will invalidate your cache. I

How to use Ember Data with Nested Resources

我的未来我决定 提交于 2019-12-19 17:31:46
问题 My application backend has several resources. A model is exposed for each resource. The entry point to all other resources is through the User model. What I mean is, given a User we can find BlogPost . Given a BlogPost we can find Comments etc. In Ember terminology, we could say: User hasMany BlogPost BlogPost hasMany Comment Comment belongsTo BlogPost By backend exposes REST APIs of the form: GET /api/v1/users/1 GET /api/v1/users/1/blog_posts/1 GET /api/v1/users/1/blog_posts/1/comments/1 I'm

DS.Model date attribute parses date (YYYY-MM-DD) incorrectly

跟風遠走 提交于 2019-12-19 14:53:19
问题 I am having a issue with my DS.Model parsing dates in the format of "YYYY-MM-DD". They are always one day behind. Here is an example: http://jsfiddle.net/ZUV8v/ Using Date objects on the console I get similar results > new Date('2012-09-20') Wed Sep 19 2012 17:00:00 GMT-0700 (PDT) Is this a ember bug or a javascript bug or a Chrome bug or am I missing something? Chrome Version 21.0.1180.89 on OSX 10.7 回答1: I ran into this just the other day. According to the ECMAScript Specification 15.9.1.15

Dynamic segment in ember data adapter

一笑奈何 提交于 2019-12-19 10:11:08
问题 I'm making an app that retrieves data of an API which is not in my control. I have the following scenario: The path for retrieving the posts is /api/posts . So I configured my ApplicationAdapter as follows: App.ApplicationAdapter = DS.RESTAdapter.extend({ namespace: 'api' }); The url for retrieving comments is '/api/posts/1/comments'. You can see that the url is prefixed by the path for retrieving a single post followed by the default path /comments . Ember data defaults to /api/comments .

Adding headers after RESTAdapter initialization

早过忘川 提交于 2019-12-19 09:16:14
问题 I am trying to add an Authorization header to my adapter's request after the adapter has been initialized and used. I can add headers in a static way at the time I create my ApplicationAdapter , but I can't seem to get it use the headers in subsequent REST calls. I am trying this: var auth= "Basic " + hash; App.ApplicationAdapter.reopen({ headers: { Authorization: auth } }); I have debugged RESTAdapter in the ajax method, and the test for adapter.headers is always undefined . 回答1: The