I've encountered a similar issue, but the solution doesn't seem to work for me. I have a JSON model named "data" that represents a SAPUi5 form with comboboxes. My goal is to capture the initial state of the model when the application is first opened and preserve it. Then, I want to use this preserved state to reset the form and restore the comboboxes to their default values. At the beginning of my application:
this.getView().setModel(new JSONModel(data)); //initialize the original model
//copy the original model (global variable copyModel)
copyModel = $.extend({}, data);
Everything seems to be functioning correctly up to this point. Both models are identical. Next, I have a button triggering a reset function:
resetP: function(){
this.getView().setModel(new JSONModel(copyModel));
console.log(copyModel);
}
The first time I make a selection in the comboboxes, then click the reset button to run the reset function, the copyModel reflects the correct data. The same goes for the original data model. However, upon changing the selected value in the comboboxes again, the copyModel starts to adopt the new selection instead. It appears to be getting overwritten somehow. I'm unsure of what mistake I might be making here. Any suggestions? I also attempted using JSON.stringify instead of extend.