What I am trying to do: Create a record and not persist it yet, because some of the info required will be filled on the next route.
How am I doing it? I am generating a uuid, and assigning it to the record. And then transitioning to the new route.
createOrder() {
var d = new Date().getTime();
var uuid = 'xxxxyyyxxxxxxxxyyxyxxxyyy'.replace(/[xy]/g, function(c){
var r = (d + Math.random() * 16) % 16 | 0;
d = Math.floor(d / 16);
return (c === 'x' ? r : (r & 0x7 | 0x8)).toString(16);
});
console.log(uuid)
this.get('model.event.orders').addObject(this.store.createRecord('order', {id:uuid}));
this.transitionToRoute('orders.list.new', uuid);
The problem: The URL is as expected /orders/<order:id>/new
but, Upon transitioning the model tries to fetch the data from the server which returns in a 404, instead of using local storage or memory where the record exists.
What I want?: How can I make it use the local storage so that it doesn't result in an error.
Aucun commentaire:
Enregistrer un commentaire