- Mastering JavaScript Functional Programming
- Federico Kereki
- 82字
- 2021-07-02 22:41:10
Solution #5 - disable the button
A similar idea: instead of removing the event handler, disable the button, so the user won't be able to click. You might have a function like the following:
function billTheUser(some, sales, data) {
document.getElementById("billButton").setAttribute("disabled", "true");
window.alert("Billing the user...");
// actually bill the user
}
This also works, but we still have objections as for the previous solutions (coupling the code to the button, need to re-enable the button, harder testing), so we don't like this solution either.
推薦閱讀
- Mobile Web Performance Optimization
- Building Modern Web Applications Using Angular
- MATLAB圖像處理超級學習手冊
- 控糖控脂健康餐
- Mastering SVG
- Learning AndEngine
- Java 11 Cookbook
- ASP.NET 3.5程序設計與項目實踐
- 零基礎入門學習Python
- 飛槳PaddlePaddle深度學習實戰(zhàn)
- Simulation for Data Science with R
- Mastering Apache Camel
- UML基礎與Rose建模實用教程(第三版)
- Java從入門到精通(視頻實戰(zhàn)版)
- TypeScript全棧開發(fā)