Delete the model of the selected item and remove it from the list
*/
deleteItem: function () {
- this.getCollection().at(this.getModelIndex()).destroy();
- this.renderWorkspace();
+ var that = this,
+ model = that.getCollection().at(this.getModelIndex()),
+ message = "_unsavedChanges".loc() + " " + "_saveYourWork?".loc(),
+ callback = function (response) {
+ var answer = response.answer,
+ destroyOptions = {};
+ destroyOptions.success = function () {
+ console.log("in deleteItem's destroy success");
+ //ws.$.salesOrderLineItemBox.valueChanged()
+ //this.doPrevious();
+ /*
+ this.getCollection().at(this.getModelIndex()).destroy();
+ this.renderWorkspace();
+ */
+
+ };
+
+ if (answer) {
+ /** Seems to be, after the destroy, what would normally be handled inside the grid box
+ to refresh and remove the model from the collection is not happening because we're
+ still in the workspce. Try doPrevious() first.
+ */
+ this.getActive().doPrevious();
+ model.destroy(destroyOptions);
+ }
+ };
+ this.doNotify({
+ type: XM.Model.YES_NO_CANCEL,
+ message: "_deleteLine?".loc(),
+ callback: callback,
+ success: callback
+ });
+ //this.renderWorkspace();
},
/**
Add a new model to the collection and bring up a blank editor to fill it in