ember-data

Emberdata 1.0.0

≡放荡痞女 提交于 2019-12-11 05:31:03
问题 I'm using Laravel 4 with emberjs and I need to list a collection of relationship data on emberjs app, but L4 print collection a little bit different, and so, I am trying to change the REST serialization but no work for now.. My Ember Data version is 1.0.0-beta.7+canary.238bb5ce. somebody help? My JSON DATA: { "names": [ { "id": "1", "description": "List 2014", "user_id": "3", "squares": [ { "id": "1" } ] } ], "squares": [ { "id": "1", "name": "squa1", "role_id": "1" }, { "id": "2", "name":

Assertion failed: No model was found for '0' Django REST and Ember Adapter

守給你的承諾、 提交于 2019-12-11 05:08:56
问题 I'm getting the error with the following code: App.SearchRoute = Ember.Route.extend({ model: function(){ return this.store.find('cabinets') } }); App.SearchAdapter = DS.DjangoRESTAdapter.extend({ namespace: 'rest_framework' }); I created the model but its not formatting the JSON correctly and I'm not sure what I am doing wrong. Also if I pump in this code instead: App.Store = DS.DjangoRESTStore.extend({ adapter: DS.DjangoRESTAdapter.create({ namespace: "rest_framework" }), revision: 12 }); I

Access the host address of the RESTAdapter programmatically

拥有回忆 提交于 2019-12-11 04:48:02
问题 I would like to obtain the host address of the REST adapter in a controller or in a component. I'm using Ember-CLI, and I set up the adapter as follows: export default DS.RESTAdapter.extend({ host: 'http://localhost:9000' }); I am aware that this question has been asked here and here, but none of those approaches work in the recent Ember 1.6.0. I tried all of the following: DS.RESTAdapter.prototype.url DS.RESTAdapter.prototype.host App.__container__.lookup('store:main').get('adapter.url') App

DS.FixtureAdapter loses fixture data with hasMany async attributes

跟風遠走 提交于 2019-12-11 03:46:45
问题 Background I've already submitted a github issue with the Ember Data team, but I'd love insight into how to work around this (or if I was mistaken all along) You can see a working demo if this bug on jsfiddle The problem jsfiddle of the issue here: http://jsfiddle.net/cdownie/JxhBv/1/ Code is duplicated here for a clearer explanation. The setup I have the following data model that I'd like to test with fixtures: App.Parent = DS.Model.extend({ name: DS.attr('name'), kids: DS.hasMany('kids',

mapping nested json to ember-data model

。_饼干妹妹 提交于 2019-12-11 03:36:54
问题 I'm not using RESTAdapter so I create Ember Object and using reopenClass method and jquery ajax function for ajax requesting and the code is: OlapApp.Dimenssions = Ember.Object.extend({}); OlapApp.Dimenssions.reopenClass({ measure:Ember.A(), find:function(cubeUniqueName){ var c = Ember.A(); var xhr = $.ajax({ type: 'POST', dataType: 'json', contentType: 'application/json', url: 'http://localhost:9095/service.asmx/getDimension', data: '{"cubeUniqueName":"'+cubeUniqueName+'"}', success:

Custom request urls in Ember model

五迷三道 提交于 2019-12-11 03:35:56
问题 I am trying to use Ember data with already built REST api. It works fine for top level routes, for example I have route for courses on api side like following: app.get('/courses', app.controllers.courses.findAll) app.get('/courses/:id', app.controllers.courses.findById) Above works fine and I can easily get data with Ember Data. But problem arises with routes that have multiple levels. For example, courses can have multiple topics and topics can have multiple lectures so routes for them are

EmberJS: How to test a controller action with moduleFor of ember-qunit, which uses store of ember-data

五迷三道 提交于 2019-12-11 03:22:20
问题 I want to test a controller action like this: createNewBase: function () { var attributesForNewBase = this.get( 'model' ).getProperties( ... ), self = this, newBase = this.store.createRecord( ..., { ... } ); newBase.save().then( function ( createdBase ) { self.send( 'setBaseOfModel', createdBase ); }, function ( error ) { console.log( error ); } ); } The problem is that if I use moduleFor of ember-qunit to test this action the store is undefined. So what do I have to do or what is the correct

Get RESTAdapter host

巧了我就是萌 提交于 2019-12-11 02:38:44
问题 RESTAdapter has the possibility to specify a url for the backend: DS.RESTAdapter.reopen({ url: 'https://api.example.com' }); How can I access this property programmatically? I mean something like: DS.RESTAdapter.get('url') <-This doesn't work 回答1: You're setting the properties on the class not the instance, thats why you can't retrieve the values. There are two possible solutions. You can get the values from the prototype DS.RESTAdapter.prototype.url or you can instantiate the class and get

Calculate sub total emberjs

我们两清 提交于 2019-12-11 02:33:53
问题 I create a shop cart. I using fixture adapter. My models App.Clothing = DS.Model.extend({ name: DS.attr('string') , category: DS.attr('string') , img: DS.attr('string') , price: DS.attr('number') , num: DS.attr('number') , fullPrice: function(){ return this.get('price') + " $"; }.property('price') }) App.CartRecord = App.Clothing.extend({ numInCart:DS.attr('number',{defaultValue:1}) , fullPrice: function(){ return this.get('price')*this.get('numInCart'); }.property('numInCart','price') }) App

EmberJS hasMany relationship and Fixtures

风流意气都作罢 提交于 2019-12-11 02:23:56
问题 I'm learning EmberJS and need some help. I have two models: Catalog and CatalogCourses. Catalog has many CatalogCourses. I'm just trying to test this relationship with some fixtures. When I load a record of Catalog the relationship fixtures (CatalogCourses) doesn't load. I've been stuck on this for a couple hours, and I think it should be simple to do this, so I'm asking for your help. Here are the models: App.Catalog = DS.Model.extend({ year: DS.attr('string'), catalogCourses: DS.hasMany(