ember-data

return single record with ember-data find() and multiple params

馋奶兔 提交于 2019-12-09 15:43:03
问题 I'm trying to do a find (with ember-data) on other params than the id, two params actually. but all i get back is: "Uncaught Error: assertion failed: Your server returned a hash with the key customer but you have no mappings". After digging around in the code i see that the find method delegates to the findQuery method when given an hash, which create a DS.AdapterPopulatedRecordArray but I only return a single customer object in my json: {"customer":{ "id":24857,"name":"Kim Fransman","id

Ember.js - Get all model names

半城伤御伤魂 提交于 2019-12-09 12:55:25
问题 I'm trying to to get a list of all defined models in my Ember application (v1.8). As far as I can tell from my research, the Container.resolver works with some mysterious magic. Does the Container have a list of all active models, or is there any way to get them? Thanks :) @edit kingpin2k's answer works, but not in Ember-Cli, is there an other way? 回答1: So, for Ember Cli there isn't a direct solution I could find. However, you can work around the problem with a bit of creative coding and by

EmberJS, EmberJS/Data and Sproutcore-Datastore

限于喜欢 提交于 2019-12-09 03:39:08
问题 With the move from SproutCore 2.0 to EmberJS there was the namespace and Github repo migration. Core things seem to have moved to the http://github.com/emberjs organization Github account while there are some others that seem to have been moved to the "addons" account http://github.com/emberjs-addons. I am currently investigating EmberJS for use with a RESTful server, serving up JSON. My question is: Do I use the new http://github.com/emberjs/data code or the older http://github.com/emberjs

Initialize a jQuery plugin when the content for an Ember.View has loaded

房东的猫 提交于 2019-12-08 21:00:34
问题 DEBUG: Ember.VERSION : 1.0.0-rc.6 ember.js DEBUG: Handlebars.VERSION : 1.0.0-rc.4 ember.js DEBUG: jQuery.VERSION : 1.9.1 The controller is an Ember.ArrayContoller & the content is loaded via the DS.RESTAdapter . This is the code I think I want, but it is never executed. I want to add an observer to controller.content for the isLoaded event. App.ThumbnailScrollerView = Ember.View.extend({ tagName: "div", didInsertElement: function() { return this.get("controller.content").addObserver("isLoaded

emberjs and ember-data -creating record via form submission returns undefined

一笑奈何 提交于 2019-12-08 19:58:27
I have this jsfiddle . Everything works excepting that i can't create a new comment by submitting the comment's form. when i submit a form the console shows undefined . What I hope to achive is to grab an existing post and then create a comment that belongs to that post. So this the flow of things, a user will click on post then click a specific post title to display it and then click on add comment to comment on that post. It is important to note that at the moment, clicking on add comment button will return undefined . Relevant section of the code with the addComment and save methods. EmBlog

ember-data-1.0.0 activemodeladapter error include an `id` in a hash passed to `push`

只愿长相守 提交于 2019-12-08 19:46:23
问题 I am using ember-data and the activemodel adapter with rails and mongoid(mongodb) in the backend. Whenever I make a request to my rails app, emberjs displays the returned data but in chrome developer console it displays: Assertion failed: You must include an `id` in a hash passed to `push` the problem reproduced in a jsfiddle I have reproduced the problem in this jsfiddle . You can see a different version of thesame jsfiddle working when I use id instead of _id . Payload sent by the backend

Retain fixtures with multiple adapters per Ember environment

回眸只為那壹抹淺笑 提交于 2019-12-08 19:21:33
问题 Although the natural progression would replace the fixture adapter with another adapter, I'd like to retain fixtures for development environment while leveraging a different Ember data adapter for production. This is due to: Heavy iterations of progressive enhancement Intended to run embedded in a UIWebView from an iOS app, production configuration is tightly coupled with bridged calls to native assembly for data. Ember CLI asset compilation is based on broccoli to load either a Web or Native

Ember 2, filter relationship models (hasMany, belongsTo) and calculate computed property based on relationships

梦想与她 提交于 2019-12-08 18:48:14
问题 These are my files: Models app/models/basket.js: export default DS.Model.extend({ name: DS.attr('string'), house: DS.belongsTo('house', { async: true }), boxes: DS.hasMany('box', { async: true }) }); app/models/box.js: export default DS.Model.extend({ qty: DS.attr('number'), basket: DS.belongsTo('basket'), cartLines: DS.hasMany('cart-line', { async: true }) }); app/models/cart-line.js: export default DS.Model.extend({ qty: DS.attr('number'), box: DS.belongsTo('box'), product: DS.belongsTo(

Display the first item in hasMany ember relationship in handlebars template

感情迁移 提交于 2019-12-08 17:40:03
问题 I need to display the first item in an hasMany relationship Basically a thread could have more than 1 author but I need to display only the first one in a particular template I've the following json { threads: [ { id: 1, authors: [2,3] } ], authors: [ { id: 2, fullname: "foo" }, { id: 3, fullname: "bar" } ] } And the following models App.Thread = DS.Model.extend({ authors: DS.hasMany('author') }); App.Author = DS.Model.extend({ fullname: DS.attr('string') }); now in my template I'm tring to

ember-data: How to tell if a model's async: true relationship is loaded without triggering a load?

僤鯓⒐⒋嵵緔 提交于 2019-12-08 15:43:59
问题 I need to check if an async relationship has been loaded without triggering the load, is this possible? 回答1: There is no official way to accomplish this yet, but unofficially you can do // this will be null if not loaded, and populated if it has at least started loading if(model._relationships.yourRelationshipName) {...} 回答2: After time has passed, Ember Data 2.5 got released. One of implemented features is the ds-references feature. The references API allows to interact with your