change mouse cursor while script executes

  • 0
  • 1
  • Question
  • Updated 4 months ago
  • Answered
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!
Photo of Carlos

Carlos

  • 654 Points 500 badge 2x thumb

Posted 6 months ago

  • 0
  • 1
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 28,144 Points 20k badge 2x thumb
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
(Edited)
Photo of Tyler Parker

Tyler Parker

  • 810 Points 500 badge 2x thumb
Hi Dan, could you provide any detail about how to display a spinner while the script is running?
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 28,134 Points 20k badge 2x thumb
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()
Photo of Tyler Parker

Tyler Parker

  • 810 Points 500 badge 2x thumb
Thank you!!