Bootstrap’s modal jQuery dialog doesn’t have to be dismissed when the user clicks elsewhere

We have a Node server running, developed using the express framework and a few other components, all new to me. I’m no Node expert… actually I hate it, and estimate it takes me more than five times longer to develop anything in this mess (using IntelliJ Idea IDE) as I skip from file to file, writing bits and pieces of code here, there and everywhere without a fluid workflow at all. (The other developer here wrote the system. I’m just adding new features and helping fix bugs.)

We have a nasty issue with duplicated requests being sent through to the server. It seems to be related to user workflow… i.e. tab through the controls and then hold down the Enter key (with the submit button focused), and you can get 20 to 30 requests separated by milliseconds. (This is costly as the request in question does a bank account verification, with the bank, which is charged for.)

The obvious fix here, and I don’t know for sure if this is the real issue, is to disable the buttons immediately after they are clicked.

We also use jQuery modal dialogs, of the Bootstrap variety. I’m now firing off a modal dialog that will remain on the screen after the user clicks the submit button, and until the request gets handled by the server. One thing that left me somewhat mystified in all this, is even in the examples online, you can dismiss all the modal dialogs, just by clicking somewhere else. This behaviour is not exactly what I would want, to say the least…

But the solution is right there in that page I linked to…

$('.modal-loading-data').modal({ show : true, keyboard : false, backdrop : 'static' });

In case you are too lazy to scroll to the right… backdrop : ‘static’ is the solution. This prevents the modal dialog from fucking off before you tell it to. Excuse the language, but the default option doesn’t make any sense to me.

About Jerome

I am a senior C# developer in Johannesburg, South Africa. I am also a recovering addict, who spent nearly eight years using methamphetamine. I write on my recovery blog about my lessons learned and sometimes give advice to others who have made similar mistakes, often from my viewpoint as an atheist, and I also write some C# programming articles on my programming blog.
This entry was posted in Programming and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s