ember-data

ember-data as data for d3

可紊 提交于 2019-12-12 08:16:01
问题 I would like to use my emberdata as data for creating objects within d3. I try to convert the items from the controllers model into new javascript objects and giving this new array to d3 data. here is the code App.GraphicsView = Ember.View.extend( { didInsertElement: function() { var svg = d3.select("#svg"); var data = this.get('controller').get('model').get('content'); var newData = []; for(var i = 0; i < data.length; i++) { newData.push(data[i]); } var graphics = svg.selectAll("rect") .data

Save foreign key to other Model with hasMany relation

北慕城南 提交于 2019-12-12 07:38:40
问题 I'm having the following problem. In my app I have a screen to make a new Site . But when I save the new site via an action on the controller, the languages -property isn't sent with the POST -request to the server. The template for adding a new Site is this: <form class="form-horizontal"> <div class="control-group"> <label class="control-label" for="name">Name</label> <div class="controls"> {{view Ember.TextField valueBinding="name"}} </div> </div> <div class="control-group"> <label class=

Relation is DS.PromiseMany instead model and data

本小妞迷上赌 提交于 2019-12-12 06:09:24
问题 What I need is: 1) Represent list of partners App.Partner= DS.Model.extend( { name: attr(), site: attr(), contacts: DS.hasMany('partner-contact', { async: true, polymorphic: true }) } ); 2) and names of partners contacts App.PartnerContact = DS.Model.extend( { name: attr(), phone: attr(), post: attr(), email: attr(), partnerId: attr(), partner: DS.belongsTo('partner') } ); So I have route: App.CallsMyContactsRoute = Ember.Route.extend({ //needs: "partner-contacts", model: function () { return

ember.js, How do I load related models while loading main model from server that is not support sideloading

≡放荡痞女 提交于 2019-12-12 06:08:40
问题 I'm ember.js newbie and facing daily problems :-) Today's problem is my server backend doesn't support sideloading . (If I understood 'sideload' right, it is server returns related models at once with multiple JSON root) for example, my server only returns below per request: for /api/v1/posts.json { posts: [{ id: 91, title: "ember.js" }, { id: 81, title: "ember-data.js" }] } for /api/v1/comments.json { comments: [{ id: 928, postId: 91, }, { id: 927, postId: 92, }] } When I load post model, go

How to override the primary key with a JSON API attribute

纵然是瞬间 提交于 2019-12-12 05:19:24
问题 I've got a model called "Membership" that has a string attribute "inviteToken" which I would like to use as my primary key. I've created the following serializer, but cannot get it to pick up the primary key from the JSON. app/serializers/membership.js: import DS from 'ember-data'; export default DS.JSONAPISerializer.extend({ primaryKey: 'invite-token' // also tried 'inviteToken' }); The specific error I'm getting is: Error while processing route: invitations.show Assertion Failed: You must

how do you deal with extra records that was created, but not used?

瘦欲@ 提交于 2019-12-12 04:38:06
问题 it's a common pattern to createRecord in the model hook when user enters the route. Sometimes those records remain unused, and they pops up in certain conditions, i.e. in peekAll query, although that is unwanted. How do deal with them? 回答1: If creation is the main responsibility for the route, you could destroy model on deactivate route event, for example: //route model: function() { return this.store.createRecord('modelName'); }, cleanModel: function() { var model = this.modelFor( this

Were Ember Computed Properties meant to be used with / contain asynchronous code? [closed]

 ̄綄美尐妖づ 提交于 2019-12-12 04:15:17
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I'm an experienced Ember.js developer. In guides, we can find an example of Computed Property with full name (synchronous, easy, relies on first name and last name). In the wild, we can find however lots of usages of Computed Properties in an asynchronous manner (for example

EmberJS Data hasMany sideloading with ActiveModelSerializers

早过忘川 提交于 2019-12-12 04:09:51
问题 I'm using Ember Data canary build: 1.0.0-beta.8+canary.267214b9 together with a rails back-end and ActiveModelSerializer . My configuration on ember side looks like this: App.ApplicationSerializer = DS.ActiveModelSerializer.extend() App.ApplicationAdapter = DS.ActiveModelAdapter.extend namespace: "api/v1" App.Authentication = DS.Model.extend provider: DS.attr('string') user: DS.belongsTo('user') App.User = DS.Model.extend username: DS.attr('string') email: DS.attr('string') authentications:

How to add parent object to child in a one-to-may relationship in ember js

廉价感情. 提交于 2019-12-12 04:08:12
问题 I have two models in ember.js with a one-to-may relationship. Now I want to create a new child object and need to assign an associated parent object. I can't figure out how to do this. My models are defined with the following code: model of parent-object import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), children: DS.hasMany('child') }); model of child-object import DS from 'ember-data'; export default DS.Model.extend({ name: DS.attr('string'), parent: DS

Ember 2, model.save() from component my-modal.hbs

☆樱花仙子☆ 提交于 2019-12-12 04:02:31
问题 I have this posts.hbs : {{#each model as |post|}} <a href="#" {{action 'openWriteModal' post}}> <h3>{{post.title}}</h3> {{post.text}} {{post.author.name}} </a> {{/each}} Then I open my write-modal.hbs : {{input value=model.title size="40" escape-press='close'}} {{model.author.name}} {{input value=model.text size="70" escape-press='close'}} <button {{action 'close'}}>Close</button> <button {{action 'save' model}}>Save</button> Now, this is my components/write-modal.js : export default Ember