ember-data

Deleting hasMany record and saving with ember-data

依然范特西╮ 提交于 2020-01-02 23:09:32
问题 I have a jsbin setup with my issue: http://emberjs.jsbin.com/sovub/3/edit From my example, in certain situations when I try to delete a subtitle and then save, I get the error: Attempted to handle event `pushedData` on <App.Subtitle:ember563:7> while in state root.deleted.uncommitted. If I delete the last subtitle then save, it's fine. But deleting the first subtitle, or deleting and adding new records then saving gives me the error message. Is it because I'm manually setting the IDs for each

Filtering store data in ember

℡╲_俬逩灬. 提交于 2020-01-02 20:00:57
问题 I am trying to filter some hard coded data in an Ember route which is being provided by mirage and having trouble. Either Ember moans at my syntax (when trying to use filter on the store) or it doesn't return any data when I use findAll and then use the JS filter method on the objects. Attempt 1 - Using findAll(): Route export default Ember.Route.extend({ model() { return { txSites: this.get('store').findAll('site').filter((site) => { return site.siteType === 'tx'; }) }; } }); Template

How to save models with many-to-many relationship in Ember.js?

Deadly 提交于 2020-01-02 14:32:53
问题 I'm stuck with this problem for so long that I think that I'm missing something obvious. Here's simplified model of my case: There is Patient that has all meds that he/she takes. And there is Medicine that has all patients who takes it. // Patient model Yo.Patient = DS.Model.extend({ firstName: DS.attr('string'), lastName: DS.attr('string'), meds: DS.hasMany('medicine') }); // Medicine model Yo.Medicine = DS.Model.extend({ title: DS.attr('string'), patients: DS.hasMany('patient') }); I've

Ember JS, Error while parsing Data in Transformer handeling event `didCommit` in state root.loaded.updated.uncommitted."

痞子三分冷 提交于 2020-01-02 08:31:13
问题 I am getting an error in an Ember Transformer trying a parse a date in the serialize function. Error message: "Attempted to handle event didCommit on <(subclass of DS.Model):ember1597:8260357> while in state root.loaded.updated.uncommitted." Strangely enough, the data is transmitted correctly parsed to the server. Code: DS.Transform.extend({ deserialize : function(serialized) { var array = []; if (Ember.isArray(serialized)) { serialized.forEach(function(item) { if (item.feldTyp === "DATE

Instance initializer unit test fails with “store is undefined”

瘦欲@ 提交于 2020-01-02 01:04:12
问题 After generating an example application: ember new preloadtest cd preloadtest/ ember g instance-initializer preload ember g model test-data ember g route index ember g adapter application With the following files: models/test-data.js import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), value: DS.attr( 'number' ) }); routes/index.js import Ember from 'ember'; export default Ember.Route.extend({ model(){ return this.store.peekAll( 'test-data' ); } }); instance

Ember.js order hasMany children

限于喜欢 提交于 2020-01-01 19:36:12
问题 I have a item model and each item can have many items. This can be many levels deep. I have this jsfiddle http://jsfiddle.net/rmossuk/xmcBf/3/ how do I change this to be able to have multiple levels of items and also how do I loop down each level to display them ? I also need be able to order each items children and store that order to persist to server. please can anyone show me how you can do this ? UPDATE: I have now managed to implement the Items can be many levels deep bit of this

Ember fewer requests for hasMany and belongsTo lookups

空扰寡人 提交于 2020-01-01 12:20:14
问题 I have the following three models: ConversationApp.Post = DS.Model.extend( body: DS.attr() replies: DS.hasMany('reply', async: true) author: DS.belongsTo('user', async: true) likedBy: DS.hasMany('user', async: true) ) ConversationApp.Reply = DS.Model.extend( body: DS.attr() post: DS.belongsTo('post') author: DS.belongsTo('user', async: true) likedBy: DS.hasMany('user', async: true) ) ConversationApp.User = DS.Model.extend( firstName: DS.attr() lastName: DS.attr() ) And my index route makes

Ember-data fixtures adapter not loading all data

梦想与她 提交于 2020-01-01 12:11:23
问题 I have an ember-data model definition that looks like this: Sylvius.Filter = DS.Model.extend({ title: DS.attr('string'), slug: DS.attr('string'), // Belongs to Atlas atlas: DS.belongsTo('Sylvius.Atlas'), // Has images images: DS.hasMany('Sylvius.Image'), // May have AtlasExtras extras: DS.hasMany('Sylvius.AtlasExtra'), // Structures for this filter structures: DS.hasMany('Sylvius.Structure'), // This is the path to the thumbnails sprite. // Each image will have an index on this sprite

Ember-data fixtures adapter not loading all data

为君一笑 提交于 2020-01-01 12:11:09
问题 I have an ember-data model definition that looks like this: Sylvius.Filter = DS.Model.extend({ title: DS.attr('string'), slug: DS.attr('string'), // Belongs to Atlas atlas: DS.belongsTo('Sylvius.Atlas'), // Has images images: DS.hasMany('Sylvius.Image'), // May have AtlasExtras extras: DS.hasMany('Sylvius.AtlasExtra'), // Structures for this filter structures: DS.hasMany('Sylvius.Structure'), // This is the path to the thumbnails sprite. // Each image will have an index on this sprite

Emberjs + data + rails - Uncaught TypeError: Cannot call method 'map' of undefined

我的梦境 提交于 2020-01-01 10:26:44
问题 When I am trying to load data from rails db with emberjs + ember data I am getting this error Uncaught TypeError: Cannot call method 'map' of undefined Here's the coffescript code: window.Cosmetics = Ember.Application.create Cosmetics.store = DS.Store.create revision: 4 adapter: DS.RESTAdapter.create bulkCommit: false Cosmetics.admin_user = DS.Model.extend({ name: DS.attr('string') email: DS.attr('string') }); Cosmetics.view = Ember.View.extend templateName: 'ember/views/aaa' Cosmetics.admin