Note that there are some explanatory texts on larger screens.

plurals
  1. POcreateRecord called w/o params does not add object to collection
    primarykey
    data
    text
    <p>Using:</p> <ul> <li>ember-1.0.0-pre.4.js</li> <li>ember-data.js REVISION:11</li> <li>handlebars-1.0.rc.2.js</li> </ul> <p>Please have a look at this <a href="http://jsfiddle.net/bazzel/BkFYd/" rel="nofollow">jsFiddle</a> illustrating the described problem.</p> <p>I have a list of items that are displayed in a template. The template contain a linkTo helper that let's the controller add an item to the collection and is shown as a text input on the page.</p> <p>Adding the item to the collection is done by the controller:</p> <pre><code>App.TodoItem = DS.Model.extend({ title: DS.attr('string', { defaultValue: "unknown" }) }); App.Router.map(function () { this.resource('todo_items') }); App.TodoItemsRoute = Em.Route.extend({ model: function () { return App.TodoItem.find(); } }); App.TodoItemsController = Em.ArrayController.extend({ addTodoItem: function () { App.TodoItem.createRecord(); } }); </code></pre> <p>If I want the new item to be shown is the list, I have to pass params to <code>createRecord</code>, otherwise the item is not visible. The same behaviour can be reproduced by using Chrome's inspector and then the item can be made visible as follows:</p> <pre><code>// Open the jsFiddle http://jsfiddle.net/bazzel/BkFYd/ and select 'result(fiddle.jshell.net) in the inspector, then: var item = App.TodoItem.createRecord(); // Nothing visible yet. item.set('title', 'Whatever'); // Now the text input appear with the title as its value. </code></pre> <p>Is this expected behaviour and if so, what am I missing here?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload