I have an XML fragment which I have used in 2 different views. When I click on a table row for item A - view A opens and if I click on "Save" on that page - Fragment opens. Depending upon the action the user did on the Fragment (it has 2 buttons - Yes/ Cancel), next step happens but I close the fragment at the end of the process. If I click on Item B in the table - view B opens. If I click on "Save" on this page, expectation is the same fragment should open. But instead I get a duplicate ID error.
One observation: if I use a different Fragment (similar in design) in both, the controllers issue is resolved. Everything works fine. But if same, fragment error.
Not sure why close if not working correctly. Tried destroy()
but then it gave me setInititalFocus()
undefined something like that error.
Controller A.js Similar code is in ControllerB.js
onManageConfirmation: function(oEvent) {
var ccModelObj = {
"headerText": "Hello",
"operation": "deleteItem"
};
if (!this.ABC) {
var ccModel = new JSONModel(); // required "sap/ui/model/json/JSONModel"
this.ABC= sap.ui.xmlfragment("...fragments.commons.ManageConfirmation", this);
this.getView().addDependent(this.ABC);
this.ABC.setModel(ccModel);
}
this.ABC.getModel().setData(ccModelObj);
this.ABC.open();
},
onYes: function(oEvent) {
this.ABC.close();
},
onCancel: function(oEvent) {
// in fragment also added onClose property and calling this method only
this.ABC.close();
},