Discussions

Expand all | Collapse all

change mouse cursor while script executes

  • 1.  change mouse cursor while script executes

    Posted 06-13-2018 22:05
    I have a button with the following code (which basically runs a JS script):

    "javascript:" &
                "var QBU_key = '" & [Record ID#] & "';" &
                "$.getScript(gReqAppDBID + '?a=dbpage&pagename=applypayment.js');" &
                "void(0);"

    Is it possible to add functionality so that the mouse cursor changes while waiting for the script to execute, as it takes a few seconds and impatient users click it more than once?

    Thanks!


  • 2.  RE: change mouse cursor while script executes

    Posted 06-14-2018 11:41
    You need to (1) "debounce" or (2) "oneshot" the button so the script (1) can not run more frequently  that a specified time interval or (2) can only run once. In the demo below I choose the oneshot method.

    Regarding feedback to the user, a better solution than changing the mouse cursor is to display a spinner to indicate the script is still running.

    You should implement the IOL technique and use the code in the demo below. To see the demo expose the console by pressing F12 and note that repeated clicks of the first button repeatedly log while the second button can only log once.



    Debounce Buttons
    https://haversineconsulting.quickbase.com/db/bnr9aa7c6?a=q&qid=1

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=661


  • 3.  RE: change mouse cursor while script executes

    Posted 08-02-2018 16:23
    Hi Dan, could you provide any detail about how to display a spinner while the script is running?


  • 4.  RE: change mouse cursor while script executes

    Posted 08-02-2018 16:46
    Start Spinner:
     var urlSpinner = "https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif";
        var $spinner = $('<img src=${urlSpinner}>').css({
          position: "fixed",
          top: "50%",
          left: "50%"
        }).appendTo("body");
    Stop Spinner:
    $spinner.hide()


  • 5.  RE: change mouse cursor while script executes

    Posted 08-02-2018 18:43
    Thank you!!