ember-data

Ember Data reloads associations when including a response in a PUT request

丶灬走出姿态 提交于 2019-12-10 14:55:14
问题 I have the following simple child-parent relationship. App.Parent = DS.Model.extend({ children: DS.hasMany('child') }); App.Child = DS.Model.extend({ parent: DS.belongsTo('parent') }); I have a situation where I update an instance of a Child and persist the changes with a save() . This issues a PUT request. Usually, a PUT request returns a 204 No Content but I return a 200 OK with a JSON serialization of the model as the response, e.g.: { child: { parent: 1 } } Unfortunately, this causes a

Ember Cli Inflector adjustments

泪湿孤枕 提交于 2019-12-10 14:32:57
问题 Where/how can i adjust the Ember.Inflector Class / create an instance of it that ember-cli picks up? Thanks! 回答1: I placed it in the model file and it worked fine: import DS from 'ember-data'; import Ember from 'ember'; var inflector = Ember.Inflector.inflector; inflector.irregular('nota', 'notas'); inflector.singular(/nota/, 'nota'); export default DS.Model.extend({ title: DS.attr('string'), description: DS.attr('string'), language: DS.attr('string'), body: DS.attr('string') }); 回答2: I

JSON API response and ember model names

試著忘記壹切 提交于 2019-12-10 13:41:10
问题 A quick question about the JSON API response key "type" matching up with an Ember model name. If I have a model, say "models/photo.js" and I have a route like "/photos", my JSON API response looks like this { data: [{ id: "298486374", type: "photos", attributes: { name: "photo_name_1.png", description: "A photo!" } },{ id: "298434523", type: "photos", attributes: { name: "photo_name_2.png", description: "Another photo!" } }] } I'm under the assumption that my model name should be singular but

Getting element by ID in Ember

偶尔善良 提交于 2019-12-10 13:36:18
问题 I am running two ember applications. One has the following component: import Ember from 'ember'; export default Ember.Component.extend({ tagName: 'a', click: function() { Ember.$('#wrapper').toggleClass('toggled'); } }); and the other one, has this one: import Ember from 'ember'; export default Ember.Component.extend({ tagName: 'a', click: function() { this.$('#wrapper').toggleClass('toggled'); } }); What I can't understand here is why in one application I select an element by ID using Ember.

Ember.js: How to integration test components that interact with ember-data models

混江龙づ霸主 提交于 2019-12-10 12:57:59
问题 I'm building a relatively straight-foward comment-list component. I want to pass in the commentable model (say a Post ) and have the component take care of creating, editing, deleting comments. Right now I pass around all the various actions and it's been extremely brittle. How do I create a true instance of an Ember Data model in a component integration test? My immediate thought was to import the model then .create({}) it but that errors with use this.store.createRecord() instead /* jshint

How to tell ember.js and ember-data version from ember-CLI?

徘徊边缘 提交于 2019-12-10 12:44:40
问题 Doing ember -v only shows ember cli version. How can you view ember.js version and ember data versions? 回答1: The version of ember.js and ember-data is determined by your app's dependencies. Bower dependencies are listed in bower.json file. npm dependencies are listed in your package.json file. In the command line, you can just use cat and grep to show you relevant lines. For example, in the app's directory (same place you use ember -v ): cat bower.json | grep ember-data That will return any

Ember 1.0.0 RESTAdapter failure

ⅰ亾dé卋堺 提交于 2019-12-10 12:32:49
问题 I can't seem to track down the source of this error: Assertion failed: No model was found for '0' The JSON is getting fetched by the server, but the app is erroring out before it gets sent to the template. The problem seems to be happening between the REST adapter and the router. The template renders error-free when I use the fixture adapter. I'm using Ember and Handlebars versions 1.0.0. Here's my App code: window.App = Ember.Application.create(); App.ApplicationAdapter = DS.RESTAdapter

Class to integrate emberjs <-> PHP with JSON data

拥有回忆 提交于 2019-12-10 12:08:04
问题 I am looking something like emberjs-data but for PHP? Longest description: I am looking class in PHP to generate JSON for emberjs in standard format and get this data in emberjs. And with other side, i want send data from emberjs to PHP using the same JSON standard. 回答1: In fact, you are looking for the PHP equivalent of ActiveModelSerializers. Did you looked at http://www.phpactiverecord.org/docs/ActiveRecord/Serialization? 来源: https://stackoverflow.com/questions/11528726/class-to-integrate

Ember.js data transition after version upgrade

随声附和 提交于 2019-12-10 11:13:06
问题 So I'm writing a POC app, and I am running into an issue after upgrading my Ember library to RC1. I noticed that when I was transitioning to a route in the new version, a stringified version of the object appears to show up in the URL, like so... http://localhost:3000/posts/<App.Post:ember269:511401b8c589137c34000001> The routes work successfully when transitioned to like this, but obviously trying to visit a URL like that a second time won't work. So I figured I would edit my code to

Clear data from Ember's Store before doing findAll

我是研究僧i 提交于 2019-12-10 10:45:11
问题 Using Ember 1.11 I have a search function working that will run a parameterized find(), but then I want to be able to go back to the state before the find, with only the records that were there before. In my app, this is the records the API returns with no query parameters. My route's model hook model: function(params) { if (params.q) { return this.store.find('project', params); } else { return this.store.findAll('project'); } } However, what currently happens is when the user goes back (by