Search code examples
ibm-mobilefirstworklight-studioworklight-runtime

Is it possible to update text message in WL.BusyIndicator?


I create a new WL.BusyIndicator via this code just before I start a long running process...

if (gblShowBusyIndicator) {
    busyIndicator = new WL.BusyIndicator('loader', 
        {text: 'Refreshing local sales data...',
        opacity: 0.85,
        fullScreen: true});
    busyIndicator.show();
}

Is it possible to update the "text" parameter intermittently during that process? I tried calling this function, but it didn't work. Any ideas?

function setBusyIndicatorStatus(status) {
    try {
        if (busyIndicator.isVisible()) {
            busyIndicator({text: status});
        }       
    } catch (e) {
        if (gblLoggerOn) WL.Logger.debug(">> setBusyIndicatorStatus(" + status + ") failure... discarding");
    }
}

Solution

  • After some additional thought, here's how I solved the problem, but I'd like to know if there's a better way than toggling show/hide w different status messages at certain points in my code.

    Thanks!

    function setBusyIndicatorStatus(view, status) {
        if (gblLoggerOn) WL.Logger.debug(">> setBusyIndicatorStatus(" + view + ", " + status + ")");
        try {
            if (busyIndicator.isVisible()) busyIndicator.hide();    
        } catch (e) {
            if (gblLoggerOn) WL.Logger.debug(">> setBusyIndicatorStatus(" + view + ", " + status + ") failure... discarding");
        }
    
        busyIndicator = null;
    
        var options = {text: null, opacity: 0.85, fullScreen: true};
        options.text = status;
    
        busyIndicator = new WL.BusyIndicator(view, options);
        busyIndicator.show();   
    }