I am struggling to follow ember 2.0's documentation for deleting records and then redirecting to a new url. When I try, I get the following error to the console:
Error while processing route: pencils Attempted to handle event `pushedData` on <name-emberjs@model:pencil::ember523:null> while in state root.deleted.inFlight. Error: Attempted to handle event `pushedData` on <name-emberjs@model:pencil::ember523:null> while in state root.deleted.inFlight.
My files follow.
Routes:
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('pencilview', { path: '/pencils/:pencil_id' });
this.resource('pencilcreate', { path: '/pencils/new' });
this.resource('pencils');
});
export default Router;
import Ember from 'ember';
import config from './config/environment';
var Router = Ember.Router.extend({
location: config.locationType
});
Router.map(function() {
this.resource('pencilview', { path: '/pencils/:pencil_id' });
this.resource('pencilcreate', { path: '/pencils/new' });
this.resource('pencils');
});
export default Router;
routes/pencilview.js
export default Ember.Route.extend({
model: function(params) {
return this.store.find('pencil', params.pencil_id);
},
actions: {
save(pencil){
this.store.find('pencil', pencil.id).then(function(pencil){
pencil.save();
})
this.transitionTo('pencils');
},
remove(id){
this.get('store').find('pencil', id).then(function(pencil2){
pencil2.destroyRecord();
});
this.transitionTo('pencils');
},
cancel(pencil){
this.store.find('pencil'.pencil.id).then(function(pencil){
})
}
}
});
templates/pencilview.hbs
<h2>Single Pencil View</h2>
<p>Pencil ID: {{model.id}}</p>
<p>
<label for='name'>Name</label>
{{input type="text" id="name" value=model.name}}</p>
<p>
<label for='name2'>Name2</label>
{{input type="text" id="n2" value=model.n2}}</p>
<p>
<label for='name3'>Name3</label>
{{input type="text" id="n3" value=model.n3}}</p>
<p><button {{action "remove" model.id}}>Delete</button></p>
<p><button {{action "save" model}}>Save</button></p>
{{#link-to 'pencils'}}Pencils{{/link-to}}
controllers/*
all missing except for pencilcreate.js, not applicable here
template/pencils.hbs
<h2>All Pencils</h2>
<p>{{#link-to 'pencilcreate' (query-params direction='pencils') class='btn btn-default' }}Create New Pencil{{/link-to}}</p>
<table id='pencil_allTable' class='display'>
<thead><tr><td>ID</td><td>Brand</td><</tr></thead>
<tbody>
{{#each model as |pencil|}}
<tr>
<td>{{#link-to "penciliew" pencil class='btn btn-default'}}{{pencil.id}}{{/link-to}}</td>
<td>{{pencil.brand}}</td>
</tr>
{{/each}}
</tbody></table>
<script>
$(document).ready( function () {
$('#pencil_allTable').DataTable();
} );
</script>
routes/pencil.js
export default Ember.Route.extend({
model() {
return this.store.findAll('pencil');
}
});
delete apiis hit, but the store is not updated. When transitioning topencils, it shows the old data unless I refresh the page. I will award the bounty to whomever updates their answer and solves this final puzzle piece first. If a new answer jumps in with a conglomerate of those listed below, I will check mark it and give Henry the bounty.drugsview. If you meanpencils, please show the route, controller ,and template.findAllis bringing it back. Please consult your server logs etc., examine your database, etc. Perhaps there's some kind of caching somewhere along the line.findAll. I preduct you'll find it contains the allegedly deleted pencil.this.store.findAll('pencil', { reload: true });