How can I disable double click on Jquery Modal Dialog button? -


let me know I am using the jquery model dialog after depositing some data in the server side and saving it in the database; Here is my modal dialog code:

  function loadUserDialog (tag, event, target, id) {event.preventDefault (); $ .validator.unobtrusive.parse ('# frmModalPopup'); Var $ loading = $ ('& lt; img src = "@ Url.Content (" ~ / content / images / ajaxLoading.gif ")" alt = "loading" class = "ui-loading-icon" style = "margin : 150px 150px; "& gt; '); Var $ url = $ (tag) .attr ('href'); Var $ title = $ (tag) .attr ('title'); Var $ dialog = $ ('
& lt; / div & gt;'); $ Dialog.empty (); $ Dialog Append ($ loading) .load ($ url) .dialog ({autoOpen: false, title: $ title, width: 500, model: true, minhite: 400, show: 'fade', hide: 'fade'}); $ Dialog.dialog ("option", "button", {"submit": function () {var dlg = $ (this); if (IsValidUserName ()) and $ ('# frmModalPopup') is valid () .form ()) {$. Ajax ({url: $ url, type: 'post', data: $ (target). Serialize (), success: function (response) {var cid = $ (response) .attr ('id'); if (cid ! = Null & cid! = Undefined) {$ (North). FadeIn ('slow') .adv; $ (window) .scrollTop ($ ('(' # '+ cid) .offset () ; Top);} dlg.dialog ('close'); dlg.empty ();}, error: function (xhr) {alertMessage ("Email ID is already in use!"); $ Validator.unobtrusive.parse ( '# FrmModalPopup');}})}}} "Cancel": function () {$ (this) .dialog ('close'); $ (this) .empty ();}}); $ Dialog.dialog ('open'); };

But when I click on more than one click on the Submit button (more than once), the form gets accumulated more than once and I get duplicate data submission information. Can you please tell me how to double click or click the Disable multiple buttons button. Disable

Check on previously submitted dialog, check that it is disabled before proceeding. Given, come back if already disabled.

  "submit": function () {if ($ (this) .hasClass ("disabled")) return; $ (This) .addClass ("disabled"); // to continue; }   

Edit: When you disable it, you can use this approach to add some additional user interface accountability by adding "working ..." or any other message

  $ (this) .addClass ("disabled"); $ Dialog.append ("Working ...");    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -