I am trying to build a simple Todo List using all the last routes and data stuff for ember. You can find my full repo here
I have my store set up like so:
EmberTodo.Store = DS.Store.extend({ revision: 11, adapter: DS.RESTAdapter.create({bulkCommit: false}) });
The line of code that is giving me trouble comes from here:
EmberTodo.CreateItemView = Ember.TextField.extend({ insertNewline: function() { EmberTodo.Item.createRecord({description: this.get('value')}); this.set("value", ""); } });
From what I understand, calling createRecord
doesn't create the record, but instead I need to call commit()
somewhere. However, I cannot figure out where. Anyone have any ideas?
From what I understand, calling createRecord doesn't create the record, but instead I need to call commit() somewhere. However, I cannot figure out where. Anyone have any ideas?
Sure. To get this working with the smallest possible
EmberTodo.CreateItemView = Ember.TextField.extend({ insertNewline: function() { item = EmberTodo.Item.createRecord({description: this.get('value')}); item.get('transaction').commit(); this.set("value", ""); } });
I've placed a simplified, working example using DS.FixtureAdapter here: http://jsbin.com/ugipap/1/edit
Done, right?
Kinda. Thing is, you really don't want to be doing this kinda thing from within a view. Consider refactoring to move this logic into the controller layer, or possibly the router depending on the situation.