How close a Busy Dialog "inside" of callback function from OData success function, which was created "outside"?

sapui5

686 просмотра

1 ответ

550 Репутация автора

Before I make an OData create entity, I show a busy dialog control showing "Processing..." menssage. I want to close that busy dialog inside of success or error callback functions according to the situation, but I can't access to the busy dialog object... Someone can help me?

Code:

//Create Busy Dialog
var oBusyDialog = new sap.m.BusyDialog({
    title: this.getResourceBundle().getText("Processing"),
    type: "Message",
    afterClose: function() {
                oBusyDialog.destroy();
    }
});

//Trigger a POST request to the odata service...
this.getView().getModel.create('/MyEntitySet', myEntityObject, {
    success: function(){
                 oBusyDialog.close();
                 (...)
             }.bind(this),
    (...)
});

Thank you!

Автор: carlosfcmendes Источник Размещён: 18.07.2016 04:51

Ответы (1)


1 плюс

4462 Репутация автора

Решение

You bound your success function to this so you can store busy dialog instance as some property and it will be available inside your success function. Like this:

//Create Busy Dialog
this._oBusyDialog = new sap.m.BusyDialog({
    ...
    }
});

//Trigger a POST request to the odata service...
this.getView().getModel.create('/MyEntitySet', myEntityObject, {
    success: function(){
                 if (this._oBusyDialog) {
                   this._oBusyDialog.close();
                 }
                 (...)
             }.bind(this),
    (...)
});
Автор: slkorolev Размещён: 19.07.2016 08:03
Вопросы из категории :
32x32