ember-data

Ember: Remove models in one request

白昼怎懂夜的黑 提交于 2019-12-11 23:17:35
问题 I know how to delete multiple models with one line of code: models.invoke('destroyRecord') But this results in x calls voor x items. Is there a way to say in Ember Remove all models with one call, where the ids are submitted as request data ? Of course I can do it by writing my own ajax request models.invoke('deleteRecord'); Ember.$.ajax({ url: ..., type: 'DELETE', data: JSON.stringify( models.map(function(model) { return parseInt(model.get('id')); }) ), contentType: 'application/json' })

EmberJS: bootstrap modal refuses to re-open due to record not being correctly deleted?

被刻印的时光 ゝ 提交于 2019-12-11 20:47:15
问题 The Goal: The thing that I am really trying to accomplish here is gain an understanding how to work with model records cleanly. In this particular case, these records are kind of "one-offs". If the modal is closed without saving, then they are meant to be cleared from memory... and once a record is saved to the server there is also no need to keep the re record stored client side. Description: I created a button action that transitions into a "payment" route, which renders inside a Bootstrap

Customize path on a per-model basis, for the REST adapter

萝らか妹 提交于 2019-12-11 19:59:51
问题 According to the URL conventions, it is possible to customize the pluralization, endpoint path and host for the REST adapter. I have a model called VoiceMenu , and the adapter is performing requests to api/voice-menus/ , as per the URL-conventions. But they should instead be sent to api/voicemenus/ . I do not want to change the name of my model. How can I configure the REST adapter, for this particular model? 回答1: Assuming you have api set already on your adapter, you can set the url on a per

Ember.js error: Object Photo has no method 'eachRelatedType'

筅森魡賤 提交于 2019-12-11 19:37:11
问题 I’m trying to create some routes that filter out approved and disapproved photos from my model (based on a boolean value). Here’s my main photos , approved and disapproved routes: # router.js App.Router.map -> @resource "photos", -> @resource "photo", path: ":photo_id" # additional child routes @route "approved" @route "disapproved" # photos_routes.js App.PhotosRoute = Ember.Route.extend( model: -> App.Photo.find() ) App.PhotosApprovedRoute = Ember.Route.extend( model: -> @store.filter "Photo

emberjs assertion failed error

不羁岁月 提交于 2019-12-11 19:21:29
问题 I am trying to insert data from ember's view but am getting following error message: Uncaught Error: assertion failed: Your server returned a hash with the key refunds but you have no mapping for it and here is my coding can anyone correct it. My handlebar <form> <th>{{view Ember.TextField valueBinding="refund_amount" placeholder="Enter refund amount"}}</th> <td><button type="submit" class="btn btn-success complete-btn" {{action saveRefund}}>Refund</button></td> </form> My js model Office

How to hit non REST endpoints with Ember Data 1.0 beta

雨燕双飞 提交于 2019-12-11 18:55:45
问题 My API is mostly restful except I have a /search endpoint on some resources. I'm using the DS.ActiveModelAdapter and DS.ActiveModelSerializer and everything is great. My current implementation for search is somewhat like this: makeAPICall: -> @set('loading', true) states = @get('selectedStates') statesString = states.join(',') query = @get('searchParam') url = "/api/v1/organizations/search?#{statesString}&query=#{query}" $.get(url).then (data) => @get('store').pushPayload(data) # TODO this

Cannot create record after ember-data upgrade

拥有回忆 提交于 2019-12-11 18:38:59
问题 After the latest ember-data 1.0 release, I have had some problems creating records. I read in the release notes - https://github.com/emberjs/data/blob/master/TRANSITION.md that: App.NewPostRoute = Ember.Route.extend({ model: function() { return App.Post.createRecord(); } }); is now replaced with: App.NewPostRoute = Ember.Route.extend({ model: function() { return this.store.createRecord('post'); } }); However in my controller I cannot figure it out how to call the createRecord() method, as I

Ember getting content from another controller doesn't work with local storage adapter

泪湿孤枕 提交于 2019-12-11 17:58:21
问题 Getting content from another controller via this.get("controllers.index.content") or this.get("controllers.index.arrangedContent") (for sorted content) doesn't work when using the ember-localstorage-adapter on the backend. For example, getting content from another controller: App.StartController = Ember.ObjectController.extend({ needs: 'index', someFunction: function() { // get the "content" from the IndexController var names = this.get("controllers.index.arrangedContent"); alert(names

EmberJS - How to print values from Model outside of {{each}} type functions

青春壹個敷衍的年華 提交于 2019-12-11 15:39:51
问题 My model (medid) is successfully loaded on my template (medid.hbs) but when I try to put a value from the record in as text it doesn't render anything. In other templates everything I rendered from the model was in a table iterated on with an {{each}} helper. Here I used {{model.id}} to populate the table rows. I assumed that I could just use something like 'Hello my name is {{model.id}} but that doesn't work. I'm probably missing something obvious How do I access my model data for printing

In Ember.js how do I create a computed property that references first item in property containing an array

限于喜欢 提交于 2019-12-11 14:57:15
问题 I have quiz fixtures that have a property called questions, which is an array of ids of associated questions. I want to create a computed property on the model called firstQ that returns the first id in the questions array. Ultimately I would like to take that id and use it to link to a question route I have created. I can not figure out though, how to access that first id in the questions array. Is this even the best way to approach this? Please help. App.ApplicationAdapter = DS