- 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.
推薦閱讀
- Google Flutter Mobile Development Quick Start Guide
- 自然語言處理實戰:預訓練模型應用及其產品化
- Vue.js 2 and Bootstrap 4 Web Development
- JavaScript+jQuery開發實戰
- Learning ASP.NET Core 2.0
- Amazon S3 Cookbook
- Building a Quadcopter with Arduino
- HTML5+CSS3網站設計基礎教程
- C語言程序設計學習指導與習題解答
- 數據結構案例教程(C/C++版)
- 基于Struts、Hibernate、Spring架構的Web應用開發
- Instant PHP Web Scraping
- Geospatial Development By Example with Python
- Modern C++ Programming Cookbook
- Visual Basic程序設計(第三版)