Hey, i'm using ajaxform to submit form. But before submiting i use a BlockUI plugin to confirm that submition. If user clicks Yes - everything fine, but if he clicks No ar first and then submits form again and presses Yes, then my ajaxSubmit does his submition twice (or more, depending on how many times in a row user clicks No before) How to avoid this thing?
Here's my code (those "Insert (back) DOM element" are to copy the dom element back to page, as i use different Forms on one page that needs different confirmation messages. Tried using Clone method but somehow it didn't work, but maybe there are mo Intelligent ways of doing the same thing?) $(document).ready(function(){ $(".ajaxForm").livequery('submit', function() { var formData = this; var domConfirm = $(formData).next('.ajaxFormConfirm'); var domAlertMsg = $(formData).nextAll('.ajaxFormAlert'); $.blockUI(domConfirm); //CONFIRM $('#yes').one("click",function() { $(formData).ajaxSubmit({ dataType: 'xml', success: function(data) { var value = $('value', data).text() alert(value) $(domAlertMsg).prepend("<div id='blockUI-Text'>"+ value +"</ div>"); $.blockUI(domAlertMsg); $('#ok').one("click",function() { $.unblockUI(); //Insert (back) DOM element. $("#blockUI-Text", domAlertMsg).remove(); $(formData).after(domAlertMsg); $(domAlertMsg).hide(); $(formData).after(domConfirm); $(domConfirm).hide(); }); } }); }); $('#no').one("click",function() { $.unblockUI(); //Insert (back) DOM element. $(domAlertMsg).prepend("<div id='blockUI-Text'>test</div>"); $("#blockUI-Text", domAlertMsg).remove(); $(formData).after(domAlertMsg); $(domAlertMsg).hide(); $(formData).after(domConfirm); $(domConfirm).hide(); }); return false; }); }); Thanks in advance.