ember-data

Dynamically setting select key in Ember within select field

浪尽此生 提交于 2019-12-24 14:00:24
问题 So I have an API that generates forms from a database. The API for the fields returns: { "formFields": [ { "module": 1, "fieldName": "Global Title", "fieldPosition": "1", "fieldType": "select", "fieldEditable": true, "dataTable": "message", "dataKey": "calling_gt", "dataValue": "id", "id": 1, "createdAt": "2015-10-15T13:59:30.764Z", "updatedAt": "2015-10-15T13:59:30.764Z" } ] } I have multiple Ember components. Essentially an Add Parameter component that loops through the fields related to

Ember: Suggestions welcome for handling inFlight errors

℡╲_俬逩灬. 提交于 2019-12-24 13:30:30
问题 I use Ember data with the REST Adapter. I want to make sure that in case of slow server responses, the application does not fail. I have simulated this bij adding at server side a sleep method of 5 seconds before returning the JSON response. If you have a form with a SAVE button, and you click this button while a previous save is still is progress, you receive a inFlight error and the whole Ember app freezes (only thing you can do is reload app). So, you can easily disable the save button by

Create and display EmberData models on same route/resource

随声附和 提交于 2019-12-24 13:24:26
问题 The app I am working on has an Event-page where users see Events from themselves and friends as well as being able to use an inline event-creator (to create events, on that very same page/route). To be a bit more precise, the events get all loaded and displayed in a newsfeed style, which works perfectly fine but the problem now is when trying to save a new event-model. I think some code will make this easier to understand. The routes: this.resource('newsfeed', function() { this.route(

Ember Data belongsTo Association (JSON format?)

这一生的挚爱 提交于 2019-12-24 13:08:04
问题 I have two models 'Author' and 'Publisher' (Rails), with a publisher hasOne author / author belongsTo publisher relationship. I have the Ember models setup correctly -- JS Fiddle -- and the associations working when I manually push into the store. But only the publisher records are created when requesting /publishers index. I've tried several types of JSON responses: Publishers with author { "publishers": [ { "id": 1, "name": "Test P 1", "author": 1 } ], "author": { "id": 1, "name": "Test A 1

Where are Ember Data's commitDetails' created/updated/deleted OrderedSets set?

你说的曾经没有我的故事 提交于 2019-12-24 11:44:25
问题 Ember Data's Adapter saves edited records in different groups of Ember.OrderedSets , namely: commitDetails.created, commitDetails.updated, and commitDetails.deleted. model.save() from model controller's createRecord() will be placed in the commitDetails.created group. model.save() from model controller's acceptChanges will placed be in the commitDetails.updated group. But I can't find in code where the placement association happens. I know that they are instantiated in Ember Transaction's

How to use ember data with nested hasMany relationships?

有些话、适合烂在心里 提交于 2019-12-24 10:38:54
问题 I have some data models that look like this: App.Order = DS.Model.extend({ name: DS.attr('string'), legs: DS.hasMany('leg', {async: false}) }); App.Leg = DS.Model.extend({ name: DS.attr('string'), order: DS.belongsTo('order'), stops: DS.hasMany('stop', {async: false}) }); App.Stop = DS.Model.extend({ name: DS.attr('string'), leg: DS.belongsTo('leg'), }); The returned JSON looks like this: { "orders": [ { "id": 1, "name": "Order 1", "legs": [] }, { "id": 2, "name": "Order 2", "legs": [1] }, {

ember-data - loading data for a menu - best approach

风格不统一 提交于 2019-12-24 09:25:42
问题 I have a list of categories that are loaded on the application route: ApplicationRoute = Em.Route.extend({ model: function() { return Em.RSVP.hash({ collections: this.store.find('collection'), categories: this.store.find('category'), links: this.store.find('link') }); } }); This triggers the categories index action on the server, as expected. I am doing this because I need to load a list of categories for a menu. I also have a category route: Router.map(function() { this.route('category', {

Emberjs - unable to query for embedded model or association

你离开我真会死。 提交于 2019-12-24 08:58:56
问题 A small portion of this fiddle: http://jsfiddle.net/v2t67/ is displayed in my question, but my problem is that i am unable to query for the json of the child model ie the comment model. As of now, i can access the parent object (Post Model) from chrome developer console using the queries below and from the result that contains the parent object, in the console, i can click on it and i will see the embedded comments as shown in this screenshot: http://imgur.com/3WL4I. So how will query for the

How to update model with new records in EmberJS

左心房为你撑大大i 提交于 2019-12-24 08:51:14
问题 I have a table that gets populated based on records from a rest API. All of this works fine. Now I want to add some buttons on top of the table. When these buttons are clicked, the api is called again but this time with some parameters. Then I want the table to be updated with these new records. How can I achieve this? My template looks like this: <div id="myEmberElement"> <script type="text/x-handlebars" id="posts"> <div id="controls"> <a href="#" id="mostrated">MostRated</a> <a href="#" id=

Ember ArrayController cannot be sorted by property defined in itemController

老子叫甜甜 提交于 2019-12-24 07:01:51
问题 I want to sort an ArrayController by a property defined/computed in the itemController. See this JSBin. If you sort by firstName (defined in the model), it works fine, but if you sort by lastName (defined in the itemController), it doesn't work. Make sure to play with sortAscending: true or false. Any idea how to make this work? Here is another simpler JSBin that exhibits the same behavior (the first JSBin is closer to my actual code). 回答1: The sortable mixin is applied on the content, not on