ember-data

Ember Js nested forms

六月ゝ 毕业季﹏ 提交于 2019-12-13 07:52:08
问题 Currently I have a form called a "form A", I've created a number of views for this form, an edit, create and list. I want to be able to create a form called "form B", that will pull through "form A's ID" as a parent ID. To enable me to have a list of all form B under a "form A" (essential a one to many relationship). So at the moment under my list for "form A" I have this link for each item: {{#link-to 'form-a.form-b.listing' form-a.id}} <!--Link to a controller --> <span class="btn btn

Access controller properties within Ember Data Transform

≯℡__Kan透↙ 提交于 2019-12-13 07:32:25
问题 I like to access a controller property within Ember Data Transform. Is there anyway how to do that? Perhaps a few words to my use case. I like to create a custom attribute 'encryptedStrings' and use DS.Transform to encrypt / decrypt the string with a given key by using Stanford Javascript Crypto Library. The key should by part a query param in the uri. get method is defined in DS.Transform but I did not get further. Here the relevant parts of the code: App.EncryptedStringTransform = DS

Ember Data serialize on fetch and deserialize on POST

99封情书 提交于 2019-12-13 06:57:04
问题 I am using ember data to get data from a remote server. My model definition is as follows - App.Publisher = DS.Model.extend({ name: DS.attr('string'), appName: DS.attr('string'), url: DS.attr('string'), appType: DS.attr('number'), streamType: DS.attr('number'), sslEnabled: DS.attr('number'), protocol: DS.attr('number'), }); And the response from the server is in the following format - { id: 1, name: "aurus", url: "1111", app_name: "superprofs", app_type: 1, stream_type: 1, ssl_enabled: 1,

ember-data error while loading route: TypeError {}

橙三吉。 提交于 2019-12-13 06:37:52
问题 I recently started to implement the ember data library into my project but now everything is broken, the google chrome console provides me with these errors: - Error while loading route: TypeError {} - Uncaught TypeError: Cannot read property 'id' of undefined - Port: Could not establish connection. Receiving end does not exist. The URL I'm trying to open is: /#/track/85 This is the relevant code: Shoutzor = Ember.Application.create(); Shoutzor.ApplicationAdapter = DS.RESTAdapter.extend({

ember.js multimodel forms: what is expected from ember-data?

徘徊边缘 提交于 2019-12-13 06:13:48
问题 I have classic multimodel form: a transport document that has many transport_document_rows, as stated in my MODELS: App.TransportDocument = DS.Model.extend number: DS.attr 'string' date: DS.attr 'string' transportDocumentRows: DS.hasMany('App.TransportDocumentRow') App.TransportDocumentRow = DS.Model.extend productName: DS.attr 'string' quantity: DS.attr 'string' transportDocument: DS.belongsTo('App.TransportDocument') I write in console this script: a = App.Invoice.createRecord(); a.get(

ember data array UI not updating on pushObject

有些话、适合烂在心里 提交于 2019-12-13 05:59:06
问题 I have a list of product-tag that I fetch for my model. Route: model: function() { return { product_tags: this.store.find('product-tag', {merchant: merchId}) } } I have a component that adds tags to the model, however when after I create the record and push it into the model (as suggested on other posts) my UI still isn't updating. addTag: function(name) { tag = this.store.createRecord('product-tag', { name: name }); this.model.product_tags.toArray().addObject(tag); tag.save(); } //model

Setting the inverse option dynamically/conditionally in ember-data?

99封情书 提交于 2019-12-13 05:30:18
问题 I'm trying to implement a full scale friending system with Ember (with friend requests that can be accepted or rejected, the ability to cancel friend requests, and unfriending). In order to do this, I have my Rails backend pass three different friendship arrays via JSON to ember, which are captured in the following ember models (extraneous stuff removed): App.User = DS.Model.extend name: DS.attr('string') friendships: DS.hasMany('friendship', { inverse: 'user' }) requestedFriendships: DS

Ember-data Serialize/Deserialize embedded records on 3rd level

萝らか妹 提交于 2019-12-13 05:15:28
问题 Pardon me for coming up with this title but I really don't know how to ask this so I'll just explain. Model: Group (has) User (has) Post Defined as: // models/group.js name: DS.attr('string'), // models/user.js name: DS.attr('string'), group: DS.belongsTo('group') // models/post.js name: DS.attr('string'), user: DS.belongsTo('user'), When I request /posts , my server returns this embedded record: { "posts": [ { "id": 1, "name": "Whitey", "user": { "id": 1, "name": "User 1", "group": 2 } } ] }

Registering models from another namespace with the Ember Data store

余生颓废 提交于 2019-12-13 04:40:38
问题 I'm working on a shared library that has internal Ember Data Models that are used by the calling application. However, those DS.Model objects from the library don't find their way into the store for the calling application. library.js DS.SharedLibrary.User = DS.Model.extend({}); DS.SharedLibrary.BaseModel = DS.Model.extend({ createdBy: DS.belongsTo('DS.SharedLibrary.User') }); app.js App.MyModel = DS.SharedLibrary.BaseModel.extend({ customField: DS.attr() }); However, when the adapter goes to

How do I create a polymorphic 1:1 relationships wtih Ember Data fixtures?

a 夏天 提交于 2019-12-13 04:19:40
问题 Page has a polymorphic 1:1 relationship with a model called PageContent. PageContent has two subtypes (TextOnly and Video). I want to be able to able to do a findAll for "page" and get all of the content back. What am I doing wrong? JSBin 回答1: This seems to work: http://jsbin.com/names/1/edit Only wrong thing I could see is the App.Page.FIXTURES. It should be: App.Page.FIXTURES = [ { id: 1, title: "Introduction", pageContent: 1, pageContentType: "textOnly" },{ id: 2, title: "Summary",