ember-data

Ember Data only populating the “id” property

删除回忆录丶 提交于 2020-01-13 18:13:08
问题 Problem: The JSON is received from the server, but only the id property have a value. The GUI only displays the String "2 1", and the {{photoName}} is ignored. Manually calling MyApp.PhotoController.get('content').objectAt(0).get('photoName') returns undefined , whereas MyApp.PhotoController.get('content').objectAt(0).get('id') returns the correct ID. Any Sugggestions ? //My Model: MyApp.Photo = DS.Model.extend({ id: DS.attr('number'), photoName: DS.attr('string'), photoDescription: DS.attr(

how to communicate with Rails in Ember

假如想象 提交于 2020-01-13 06:50:10
问题 Let me explain shortly what I mean. I'm writing an app that makes use of Ember and Rails. Every employee can give other co-workers a kudo. He can't know how many others received. I can only know how many left kudos I have to give and how many I received from others. But I can't really understand how to communicate with Rails. As a picture is worth a thousand words, please take a look at this: kudos app http://wstaw.org/m/2013/03/25/kudos.png When the app starts I load a list of users pointing

Ember-Data Fixture Adapter

僤鯓⒐⒋嵵緔 提交于 2020-01-13 06:01:50
问题 Is there a commit method for the fixture adapter? What does it do? As my understanding goes store.commit() puts an API call when used with REST adapter. Can I use isLoaded property with fixture adapter? Basically I have 2 records in my controller called x and y and a property content that has many records of y type. Coffee code below: someMethod: (-> content.removeObject(y) ).('x.isLoaded') anotherMethod: -> //modify x Application.store.commit() When I call anotherMethod it updates x and runs

Ember Getting property from Controller in Model

房东的猫 提交于 2020-01-13 03:25:31
问题 I have a computed property on a model and in order to compute that I need a property from a controller (not the one that is controlling the model). I know there is needs: but this is just on a controller level. How could I get a property in Ember from a controller other than the one that is managing the model? I'm trying to do some formatting like the person that [asked this question][1] but I didn't succeed what has been suggested there. So I try to do the formatting on the model with a

Dynamically add js object to model array in 1.13

六月ゝ 毕业季﹏ 提交于 2020-01-12 11:45:54
问题 I have the following code: var msg = this.store.createRecord({text:'first title', createdAt: "2015-06-22T20:06:06+03:00" }) this.get('model.content').pushObject(msg); msg.save(); We create new record. Then push in it to the model to display. It worked perfectly in 1.9 version but after upgrading it to the newest 1.13 it breaks and shows this error: TypeError: internalModel.getRecord is not a function after some researches I came out to this solution this.get('messages.content').unshiftObject

Iterating over Ember.js ember-data Record Arrays

拜拜、爱过 提交于 2020-01-12 07:32:24
问题 I've been beating my head against this problem all day, and I feel like I'm close to a solution but just can't quite make it happen. I'm using Ember.js with Ember-Data and the Fixtures adapter, eventually migrating to a REST adapter. The basic problem is this: I have Sites and Supervisors, with a many-to-many relationship. I want to present the user with a select box for their existing site/supervisor pairings, sorted by site, ie: Site 1 - Supervisor 1 Site 1 - Supervisor 2 Site 2 -

Injecting session into a model

試著忘記壹切 提交于 2020-01-11 04:20:06
问题 I'd like to be able to inject my Session singleton into my Ember models. The use case I'm trying to support is having computed properties on the model that react to the user's profile (a property on the Session object). App = window.App = Ember.Application.create({ ready: function() { console.log('App ready'); this.register('session:current', App.Session, {singleton: true}); this.inject('session:current','store','store:main'); this.inject('controller','session','session:current'); this.inject

create temporarty non persistent object in Ember-Data

流过昼夜 提交于 2020-01-10 02:57:32
问题 I want create an object using ember-data, but I don't want to save it until I call commit. How can I achieve this behavior? 回答1: You can use transaction 's, defined transaction.js with corresponding tests in transaction_test.js. See an example here: App.store = DS.Store.create(...); App.User = DS.Model.extend({ name: DS.attr('string') }); var transaction = App.store.transaction(); transaction.createRecord(App.User, { name: 'tobias' }); App.store.commit(); // does not invoke commit transaction

Ember-Data: How do “mappings” work

本小妞迷上赌 提交于 2020-01-09 09:10:15
问题 I'm currently trying to put something together with ember + emberdata + router + asp.net web api. Most of it seem to work, however I stuck in an error message I get when ember-data tries to findAll through the adapter for my models. In my backend I have a model like this (C#): public class Genre { [Key] public int Id { get; set; } [Required] [StringLength(50, MinimumLength=3)] public string Name { get; set; } } Which in my app I represent it like this using ember-data: App.Genre = DS.Model

Ember-Data: How do “mappings” work

妖精的绣舞 提交于 2020-01-09 09:10:12
问题 I'm currently trying to put something together with ember + emberdata + router + asp.net web api. Most of it seem to work, however I stuck in an error message I get when ember-data tries to findAll through the adapter for my models. In my backend I have a model like this (C#): public class Genre { [Key] public int Id { get; set; } [Required] [StringLength(50, MinimumLength=3)] public string Name { get; set; } } Which in my app I represent it like this using ember-data: App.Genre = DS.Model