ember.js - Ember Data 'find' with parameters prevent new record from displaying -
I am trying to add a new record to the amber data store, and it is expected to show up immediately in the amber data store The parameter was spent a few hours trying to figure out how to pass it.
Then this code works:
app.flags root = amber Route.product ({model: function (params) {this return.store.find ('flag');}}); App.FlagsController = Ember.ArrayController.extend ({init: function () {this.store.createRecord ('flag');}}); JSBin:
At the bottom of the table is a new record, as expected.
And the only thing I'm adding is the parameter for the 'search' query, it stops working.
This code therefore displays the new record:
App.FlagsRoute = Ember.Route.extend ({Model: Functions (Params) {this return.store. Find ('flag', params);}}); JSBin:
The new record has actually been added to the amber data store, but not shown in the table.
Your problem is that you have a record in your controller's init The hook is called the model hook of your root that your controller has been instituted for the first time, so it is not getting a record because it does not exist. The first thing is because the called method, called with no parameters, returns an array that updates as new records are added. Calling with the parameter does not do this. Your init function is a terrific place to record a record in any way. You should not deal with any kind of continuous state of that function. Ideally, as a result of user interaction, record controllers must be created at runtime. If you give us a bit more information about your use case and how you want to create a new flag, then I can help you a bit more.
Comments
Post a Comment