ember-data

How do you use ember.js with external (non-local) api endpoints?

穿精又带淫゛_ 提交于 2019-12-11 02:07:40
问题 Has anyone had success working with a front-end only applications with Ember.js and consuming endpoints from an external host? If so please share your experience. Here are a couple of options. Make the requests through a local proxy (just pass through). Use a proxy + Rails so that you can work the way Ember.js wants you to. Use CORS requests to get around the XSS issue. It seems like the canonical approach to Ember.js is to use a local Rails app to serve up json to an Ember.js app. From what

Ember.js Controller Does not work

泪湿孤枕 提交于 2019-12-11 01:29:03
问题 I can't access to my array controller variables. I have this simple application for example: App.js App = Ember.Application.create(); App.ApplicationAdapter = DS.FixtureAdapter.extend(); App.Router.map(function() { this.route('hello'); }); App.IndexRoute = Ember.Route.extend({ redirect: function() { this.transitionTo('hello'); } }); App.HelloController = Ember.ArrayController.extend({ name: 'tom' }); App.HelloRoute = Ember.Route.extend({ model: function() { return this.store.find('hello'); }

Sending additional parameters with Ember Data

北城余情 提交于 2019-12-11 01:10:38
问题 I'm using Pusher with EmberJS and Ember Data. To avoid the push notifications coming back to the same client, I would like to always send the Pusher socketId with each API call. I can get the socketId from within my controller's actions, but don't know how to send it back. e.g. var socketId = this.pusher.get('socketId'); var project = this.get("model"); project.save(); The problem is, the socketId will be different for each controller. So I can't do it directly in the adapter. Something like

Ember-data “Cannot call method 'hasOwnProperty' of undefined”

大城市里の小女人 提交于 2019-12-11 01:06:58
问题 I have the following Ember.js model: Filters.Milestone = DS.Model.extend({ id: DS.attr('string'), name: DS.attr('string') }); In my app.js I have the following settings for the model (loaded prior to the model): Filters.MilestoneSerializer = DS.RESTSerializer.extend(); Filters.MilestoneAdapter = DS.RESTAdapter.extend({ namespace: "ember" }); When loading the page, an AJAX call to the milestones list is done. The following JSON is returned: { "milestones": [ { "id": "1", "name": "Test

createRecord with ember-data + ember-data-django-rest-adapter

无人久伴 提交于 2019-12-11 00:59:01
问题 I'm currently working on creating an ember application using ember/ember-data/ember-data-django-rest-adapter with Django backend. I'm having issue creating record when there's belongsTo and hasMany relationship going on. I currently have this code: App.Article = DS.Model.extend({ title: attr(), description: attr(), authors: hasMany('author'), category: belongsTo('page'), slug: attr(), content: attr(), articleContent: Ember.computed.alias("content"), published: attr(), publish_from: attr(),

Force ember-data to re-load specific record from server

五迷三道 提交于 2019-12-11 00:29:39
问题 Lets say I have 2 nested resources for posts. It is defined like this in my router. this.resource('posts', function () { this.resource('post', {path: '/:post_id'}); }); Each post can then also have multiple related comments. In my *posts_route.js* i set up the model like this: return this.get('store').findAll('post'); This makes a GET request to my backend api which returns all posts as json. At this point I only need basic information (and no comments), so not all the data is included in the

Emberjs: Prevent changes propagation throughout a transaction

混江龙づ霸主 提交于 2019-12-11 00:28:54
问题 I have a scenario where I list products in a page and allow users to edit products' properties only in a modal window. When a user clicks on the product and start editing the product's properties, changes gets propagated right away to the product in the product list page and any part of page bound directly or indirectly to the property undergoing the changes. Not the desired behaviour. Changes should be propagated only when the user confirms the changes i.e save button clicked, transaction

get data from emberjs store.find

…衆ロ難τιáo~ 提交于 2019-12-10 23:55:56
问题 I have a route with model person: export default Ember.Route.extend({ model: function(){ return this.store.findAll('person'); } }); I want to modify the data in this model in my controller: export default Ember.Controller.extend({ actions:{ justLog: function(){ this.get('model') // ??? } } }); but this.get('model'); returns Class {store: Class, isLoaded: true, manager: Class, isUpdating: false, __ember1463955537869: "ember357"…} and i cant get the data out of it. 回答1: You have two choices,

Saving parent_id relationship with ember data

五迷三道 提交于 2019-12-10 22:51:22
问题 Okay. I've had a real good look through SO and other sources returned by Google, but am yet to find an answer to my problem. I have two models: App.Kid = Ember.Model.extend title: DS.attr "string" parent: DS.belongsTo "App.Parent" App.Parent = Ember.Model.extend title: DS.attr "string" kids: DS.hasMany "App.Kid" Most questions on here discuss retrieving ember data relationships from sideloaded JSON data, which I'm capable of doing. What I need to know is how do I save the parent_id when

When Loading Detailed Entry and Then List of Entries, Ember Data Removes Fields Not Set In List Response

五迷三道 提交于 2019-12-10 21:26:57
问题 I have a Book model, with several attributes, e.g. title , author and prices . prices is a large list of historical pricing information. When I request a list of books from the API, I exclude the prices field to keep the response small. On a book detail view, I request the complete book information (and render a chart using d3). ember-data fetches the single book from the API, updates the model and everything is fine. My book single page is a nested resource of my book list resource: App