ember-data

how to unit test controller which uses this.get('store')

若如初见. 提交于 2019-12-11 08:13:03
问题 I am unit testing my controller using mocha. My controller looks like: AS.MyController = Ember.ObjectController.extend(Ember.Validations.Mixin, { name: null, description: null, init: function () { this._super(); this.get('store').find('something'); }, .... }); And my test begins like: describe("MyControllerTest", function () { //tried but didn't work //delete AS.MyController.init; var controller = AS.MyController.create(); ..... }) and the browser always throws error on "this.get('store')"

Ember: Model's property changes not detected in computed property

萝らか妹 提交于 2019-12-11 08:07:44
问题 I have 2 models. models/calendar.js export default Model.extend({ holidays: hasMany('holiday'), date: attr(), occasion: attr() }) models/holiday.js export default Model.extend({ calendar: belongsTo('calendar') }) And a component. holidays/component.js export default Component.extend({ init() { this._super(...arguments); this.store.find('calendar', this.get('calendarId')) .then(calendar => this.set('calendar', calendar)); }, calendarIsDirty: computed('calendar.holidays.@each.{date,occasion}',

Ember.js REST update (PUT) not working

孤者浪人 提交于 2019-12-11 07:58:12
问题 My RESTFul GET, DELETE is working however the PUT (edit) strangely enough is fail to update the database: Handlebar template for Post editing: <script type="text/x-handlebars" id="post"> <h1>View/Update Posts</h1> {{#if isEditing}} <p>Title: {{input type="text" value=title}}</p> <p>Author: {{input type="text" value=author}}</p> <p>Body: {{textarea value=body}}</p> <button {{action 'doneEditing' this}}>Done</button> {{else}} <p>Title : {{title}}</p> <p>Author: {{author}}</p> <p>Body : {{body}}

Missing options request using ember-data

耗尽温柔 提交于 2019-12-11 07:55:00
问题 I'm trying to get to grips with ember and ember data but having a problem with handling CORS correctly. I've managed to define a model etc using a static fixture but now want to use some remote JSON. So I setup ember-data like this: App = Ember.Application.create(); App.Store = DS.Store.extend({ revision: 13, adapter: DS.RESTAdapter.create({ url: 'http://clara.eagle/v1/money' }) }); A model like this: App.Transaction = DS.Model.extend({ type: DS.attr('string'), occurrence: DS.attr('date'),

Ember select for belongsTo doesn't update hasMany end

别等时光非礼了梦想. 提交于 2019-12-11 07:46:54
问题 I'm trying to change a belongsTo using the built in ember select view. However, when the select box changes only the belongs to attribute is updated, not the hasMany relationship. The following jsbin shows this behaviour http://jsbin.com/ewosiy/3/edit. In this example a person hasMany events and an event belongsTo a person. If I change who the event belongsTo, the event is removed from the original person but never added to the new person. I could roll my own select-box component but just

Embedded data from RestApi

淺唱寂寞╮ 提交于 2019-12-11 06:31:05
问题 My data comes from REST API like this: customers:[ id:3, name:"Joue", currency:{ id:5 iso_code:"BDT" } ] My model: App.Customer = DS.Model.extend({ name: DS.attr('string'), currency: DS.attr('string') }); i populated a select box with the availabe currencies and now i want to select by "id" 5. Since currency is embedded and its interpreted as string i cant access it. As far as i know embedded records are no longer supported in ember-data 1.0. do i have to rewrite my REST Api and get rid of

ember-data working as expected only if app entry point access data

牧云@^-^@ 提交于 2019-12-11 06:28:12
问题 I have a strange problem with ember-data, on one entry point it loads the data from the server (I enabled logging on the server to see what's happening), but on a different entry point and then change route to the same state as the first option, ember-data doesn't access the server at all. I simply can't understand why this is happening. in my app, if I point the browser to /posts, data is loaded from the server and everything is ok. but if I point to /settings, and then follow a link to

Ember data JSONAPI complex attribute data

a 夏天 提交于 2019-12-11 06:07:43
问题 I have a data structure as follows coming back from the server for some filter functionality I'm writing. Where each filter-group has many filters. data: [ { type: "filter-group", id: "556d7f5fa1f9de08500ef4e8_1", attributes: { name: "Colour", created-date: "0001-01-01T00:00:00Z", active: true, filters: [ { id: "556d7f5fa1f9de08500ef4e8_1_1", name: "Red", created-date: "0001-01-01T00:00:00Z", active: true }, { id: "556d7f5fa1f9de08500ef4e8_1_2", name: "Blue", created-date: "0001-01-01T00:00

ember-data Assertion failed: Cannot call get with 'query' on an undefined object

◇◆丶佛笑我妖孽 提交于 2019-12-11 05:59:59
问题 Solving my previous question (ember-data error while loading route: TypeError {}) Turned up a new error, because I think this problem is not related to the previous question I decided to create a new question for it. The error I'm getting now is: XHR finished loading: "http://www.shoutzor.nl//api/emberstore/tracks/85/". Assertion failed: Cannot call get with 'query' on an undefined object. ember.js:394 Uncaught TypeError: Cannot read property '__ember1382024509870_meta' of undefined (note:

Replace Ember.ArrayController.create() will not resolve belongTo relationships | ember upgrade 3.x

戏子无情 提交于 2019-12-11 05:37:26
问题 I'm in the process of upgrading and I'm facing issues because ArrayController is being deprecated. In my old Ember 1.13 route I'm using model/announcement.js export default DS.Model.extend( { id:DS.attr('string'), title: DS.attr( 'string' ), description: DS.attr( 'string' ), published: DS.attr( 'boolean' ), publishedAt: DS.attr( 'date' ), course: DS.belongsTo( 'course' ), author: DS.belongsTo( 'profile', { async: true } ), viewed: false, isNew: true, } serializer/announcement.js import DS