- 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.
推薦閱讀
- Mastering ServiceStack
- 單片機C語言程序設計實訓100例:基于STC8051+Proteus仿真與實戰(zhàn)
- 精通搜索分析
- PHP+MySQL網(wǎng)站開發(fā)項目式教程
- 編程數(shù)學
- Python項目實戰(zhàn)從入門到精通
- Visual Studio Code 權(quán)威指南
- Julia數(shù)據(jù)科學應用
- INSTANT Premium Drupal Themes
- 透視C#核心技術(shù):系統(tǒng)架構(gòu)及移動端開發(fā)
- Continuous Integration,Delivery,and Deployment
- Learning Akka
- Getting Started with Phalcon
- 西門子PLC 200/300/400應用程序設計實例精講(第2版)
- Professional Azure SQL Database Administration