January 2020
Intermediate to advanced
470 pages
11h 13m
English
A variant to the previous solution would be not to remove the click function, but rather assign a new one instead. We are using functions as first-class objects here when we assign the alreadyBilled() function to the click event. The function warning the user that they have already clicked could be something as follows:
function alreadyBilled() { window.alert("Your billing process is running; don't click, please.");}
Our billTheUser() function would then be like the following code—and note how instead of assigning null to the onclick handler as in the previous section, now the alreadyBilled() function is assigned:
function billTheUser(some, sales, data) { document.getElementById("billButton").onclick = alreadyBilled ...Read now
Unlock full access