ember-data

Ember Data, how to use registerTransform

╄→гoц情女王★ 提交于 2020-01-22 16:26:12
问题 I've been Googling for a while now, but haven't found any good solution. The root of the problem is that my records aren't being set to isDirty when using this method: DS.JSONTransforms.object = { deserialize: function(serialized) { return Ember.isNone(serialized) ? {} : serialized; }, serialize: function(deserialized) { return Ember.isNone(deserialized) ? {} : deserialized; } } From what I gather this is an old method that apparently still works, since it handles the JSON objects I'm

Ember Data, how to use registerTransform

岁酱吖の 提交于 2020-01-22 16:25:08
问题 I've been Googling for a while now, but haven't found any good solution. The root of the problem is that my records aren't being set to isDirty when using this method: DS.JSONTransforms.object = { deserialize: function(serialized) { return Ember.isNone(serialized) ? {} : serialized; }, serialize: function(deserialized) { return Ember.isNone(deserialized) ? {} : deserialized; } } From what I gather this is an old method that apparently still works, since it handles the JSON objects I'm

Request Two Models together

 ̄綄美尐妖づ 提交于 2020-01-22 07:10:23
问题 I have two models that are many to many. They're used on the first page of my app and I'm having trouble loading them. Both models only have a handful of items (<200) and I'd like to just load both models completely in one findAll request each. But as the first model gets loaded, Ember starts fetching the missing data for the second model, item by item. If I try to just load the models separately, I get an error and have to set {async:true} for the hasMany attr. For some reason though, Ember

Ember-data resets queryParam to default value

心已入冬 提交于 2020-01-17 02:39:10
问题 In my model, I have a queryParam status which is set to refreshModel true in my route. queryParams: { status: { refreshModel: true } } In my controller, this param is set to 'opened' by default : App.ConversationsController = Ember.ArrayController.extend({ queryParams: ['status'] status: 'opened' }); Everytime I set this param to something else, for example 'all', Ember-data resets it to 'opened' and makes two calls instead of one to my model hook, and this behavior has been observed with

Expected format for validation errors in Ember Data (using ActiveModel::Serializers)

≯℡__Kan透↙ 提交于 2020-01-16 19:14:29
问题 Unfortunately, ActiveModel::Serializers does not currently support validation errors, though they're scheduled for 1.0. Until then, I've got to hack a solution of my own. The big problem? I have no idea what format Ember Data's ActiveModelAdapter expects these errors to be in. I tried simply passing in the errors property, but Ember Data didn't pick up on it: class MySerializer < ActiveModel::Serializer attributes :errors end So what should I pass in instead? 回答1: I use this method to render

Observe Ember Data store changes in component

孤街浪徒 提交于 2020-01-16 07:45:34
问题 I have a component which creates record for a specific model like this: export default Ember.Component.extend({ store: Ember.inject.service(), addRecord(account) { this.get('store').createRecord('update', { authUid: account.get('authUid'), service: account.get('platform') }); } }); I have another component that needs to observe changes done to a particular model (i.e. if records are added or deleted), and show them in that component. export default Ember.Component.extend({ store: Ember.inject

ember-data fixtureAdapter with embedded hasMany

可紊 提交于 2020-01-16 03:56:46
问题 I've been at this for a couple hours, fiddling with a number of different combinations to get this working. LO.List = DS.Model.extend({ name: DS.attr('string'), listItems: DS.hasMany('LO.ListItem', { embedded: true }) }); var lists = LO.store.findAll(LO.List), firstList = lists.objectAt(0), listItems = firstList.get('listItems'), firstListItemId = listItems.objectAt(0).get('id'); console.log(firstListItemId) // [object Object] http://jsfiddle.net/pjmorse/65eRS/ It seems that the 'embedded'

EMBER JS - Fetch associated model data from back-end only when required

别等时光非礼了梦想. 提交于 2020-01-15 12:15:09
问题 store.findRecord('school', school_id, { include: [ 'students', 'students.records' ].join(',') Using the above code fetching school, students, students' records data in inital load. In the initial load, I don't need students.records (only listing students initially) Need student records only when clicking some button (All Students Performance - to display a performance chart) Is there any way to fetch associated records separately and link with the existing model I have sperate api endpoint

Why is Firebase data not displaying properly in my Ember CLI generated output?

耗尽温柔 提交于 2020-01-15 04:49:51
问题 I've successfully setup Ember CLI and Firebase and I'm attempting to bring some basic data into my templates. My 'title' and 'subtitle' data are apparent in the Ember Inspector, as well as my Firebase project dashboard. However, {{foo.title}} and {{foo.subtitle}} are coming back empty and undefined in the browser. Why is that? Here's my code: application.js (adapter) import DS from 'ember-data'; export default DS.FirebaseAdapter.extend({ firebase: new window.Firebase('https://<firebase

How can I programatically select a drop down option using Ember?

跟風遠走 提交于 2020-01-15 04:32:05
问题 This is my sample drop down <select name="newType" class="parts-select full-width-combo" onchange={{action "loadFilter" value="target.value" }}> <option value="" selected hidden >Select </option> {{#each model as |item|}} <option value="{{item.id}}">{{item.description}}</option> {{/each}} </select> from the relevant template action I wanted to set this selected item dynamically. As an example it default selected by "Select" and then based on some button click on that page and need to set my