I am new to Ember and am trying to do a simple create / delete user. I am able to create a client, but can not delete them?
Client Controller:
export default Ember.ArrayController.extend({
actions: {
createClient: function(newName) {
// Create the new Todo model
var client = this.store.createRecord('client', {
name: newName,
avgMarkup: 2,
quotes: 1
});
// Clear the "New client" text field
this.set('newName', '');
// Save the new model
client.save();
}
}
});
I've then tried adding this:
destroyRecord: function() {
this.get('model').destroyRecord();
}
And I have no luck. My view is this:
<ul id="client-list">
<h6>Clients Name:</h6>
{{input type="text" id="new-client" placeholder="Please enter client name"
value=newName action="createClient"}}
{{#each}}
<li>
<input type="checkbox" class="toggle">
<label>{{name}}</label>
<button {{action "destroyRecord" }} class="destroy"></button>
</li>
{{/each}}
</ul>
Is this doable with an Array Controller?
Thanks
Aucun commentaire:
Enregistrer un commentaire