I have a list of items in my application, and there is a button to delete the previous one. Then on my controller I wrote the following work:
removeLastItem: - & gt; Previous item = current_order.get ('item'). ('Last Object') lastItem.deleteRecord () App.store.commit () My problem comes when I'm pretty fast on my button But it seems that when the store has not expired () the item is still dirty, it is already calling store.commit () for another item, throwing this error: Error: Attempted to handle the ad deleteRecord on the app. ITM: ember6954: f6a1c932-2db0-4933-7c92-69fbd3838229 & gt; While rootstate.deleted.uncommitted in the state. I have already tried to put this code inside the ring or transaction, but nothing worked.
Any clues? :
You can try a different approach, for example DidDelete < / Code> event has been removed. Example:
removeLastItem: - & gt; # Get your button reference and disable it altogether IITem = current_order.get ('item'). ('Last Object') lastItem.deleteRecord () lastItem.on 'didDelete', = & gt; # Re-enable your button again Iteem.on 'made error', = & gt; # Notify your user again and again? App.store.commit () Look for information on the model lifecycle and all the events you can hear.
Hope it helps.
No comments:
Post a Comment