I am trying to set a dialog to busy using setBusy() but its not working in my controller. I use setBusy() in chrome develper tools console and it works fine. I also get an error when I try clicking the dialog twice. This is the error message:
XMLTemplateProcessor-dbg.js:98 Uncaught Error: Error: adding element with duplicate id 'inactivedialog'
at onDuplicate (Element-dbg.js:169)
at f.register (ManagedObjectRegistry-dbg.js:44)
at ManagedObject-dbg.js:528
at f.constructor (ManagedObject-dbg.js:558)
at f.constructor (Element-dbg.js:151)
at f.constructor (Control-dbg.js:172)
at new f (Metadata-dbg.js:463)
at a1 (XMLTemplateProcessor-dbg.js:1063)
at XMLTemplateProcessor-dbg.js:1070
at SyncPromise-dbg.js:308
Here is my code in controller.
var oView = this.getView();
Fragment.load({
name: "ariba.so.kaakbatransfer.view.InactiveEmployee",
controller: this
}).then(function (oDialog) {
oView.addDependent(oDialog);
oDialog.open();
}.bind(this));
var inactiveDialog = sap.ui.getCore().byId("inactivedialog");
inactiveDialog.setBusy(true);
$.ajax({
url: "private",
type: "GET",
contentType: "application/json",
success: function (data) {
this.setModel(new JSONModel(data), "inactiveemployee");
}.bind(this),
error: function (e) {
var bCompact =
!!this.getView().$().closest(".sapUiSizeCompact").length;
MessageBox.error(
"Data error. Please correct and try again. Refresh the page, if needed.", {
styleClass: bCompact ? "sapUiSizeCompact" : ""}
);
}
});
inactiveDialog.setBusy(false);
Here is my code for the fragment.
<core:FragmentDefinition id="inactivefragment" xmlns="sap.m" xmlns:core="sap.ui.core">
<SelectDialog id = "inactivedialog" noDataText="No Employees Found" title="Select Employee" search="handleSearch" confirm="InactiveEmployeeClose"
cancel="InactiveEmployeeClose" showClearButton="false"
items="{path :'private', sorter:{ path : 'name', descending : false }}">
<StandardListItem title="{private}" info="{private}" type="Active"/>
</SelectDialog>
</core:FragmentDefinition>
The inactivedialog should be busy while the ajax call runs. I should be able to do this in the controller.