Search code examples
jirajira-pluginatlassian-plugin-sdk

Acknowledging the Save button when configuring a slow-loading gadget


My gadget takes a long time to load. When the user edits the configuration and clicks Save, currently nothing happens for a long time (during which the user wonders what's going on and repeatedly clicks Save), and then (after that long time of unresponsiveness) my gadget paints what it looked like before the configuration change, and then immediately paints the new appearance.

I'd like to display some acknowledgement on Save and then paint the new appearance without first painting the old appearance.

I've identified a spot in the src/main/resources/gadgets/my-gadget.xml file where I can write to the console log that Save has been clicked at the correct moment in time, at the beginning of the period of unresponsiveness. The spot in the code is inside the argument to AJS.Gadget() inside the function defined at [view][args][ajaxOptions]. But what code can I use to replace that log entry with a visible acknowledgment -- something like AJS.$("#config").show().html("Saving...")?


Solution

  • This does thie trick in the arg to AJS.Gadget() --> view: --> args: --> ajaxOptions: --> first line of the function defined as the value for ajaxOptions:

    this.showLoading();
    

    I also found I had to have the accompanying this.hideLoading(); in view: --> template: --> first line of the function defined as the value for template: .... Without it, the Edit menu item would disappear deterministically on its second use!