2017-03-22 3 views
1

Ich reiche ein Formular von jquery.ajaxForm ein. Aber durch Doppelklick auf die Maus wird das Formular zweimal gesendet, ich möchte verhindern, dass standardmäßig auf die Schaltfläche klicken, aber in $ .ajaxForm in welchem ​​Ereignis kann ich Standard verhindern?In welcher Funktion kann Prevent Default für jquery.ajaxForm durchgeführt werden?

$('#counter-entry-form').ajaxForm({ 

      beforeSubmit: function() { 
       $('#counter-entry-form').removeData("validator").removeData("unobtrusiveValidation"); 
       $.validator.unobtrusive.parse($('#counter-entry-form')); 
       if ($("#counter-entry-form").valid()) { 
        $('#submitting-btn').attr('disabled','disabled'); 
       } else { 
        return false; 
       } 
      }, 
      success: function (result) { 
       if (result.Success) { 
        window.open('@Url.Content("~/Counter/PrintViewForSato?itemId=")' + result.ValueTwo, '_blank'); 
        $('#IsFromNameSave').attr('checked', false); 
        $('#IsToNameSave').attr('checked', false); 
        $('#submitting-btn').removeAttr('disabled'); 
        if ($('#IsBulkEntry:checked').is(':checked')) { 
         $('#BulkEntryCount').val(result.ReturnId); 
         $('#BulkEntryTotalAmount').val(result.ValueOne); 
         $('#ItemId').val(''); 
         $('#ToName').val(''); 
         $('#ToDestinationLocal').val(''); 


        } else { 

         $('#ItemId').val(''); 
         $('#Weight').val(0); 
         $('#FromName').val(''); 
         $('#FromDestinationLocal').val(''); 
         $('#ToDestinationLocal').val(''); 
         $('#ToName').val(''); 
         $('#Weight').change(); 

        } 
        if ($('#IsReset:checked').is(':checked')) { 
         $('#BulkEntryTotalAmount').val(0); 
         $('#BulkEntryCount').val(0); 
        } 
       } else { 
        WorkForce.loader.hide(); 
        ShowMessage("error", "error", result.Msg); 
       } 
      }, 
      error: function (err) { 
       WorkForce.loader.hide(); 
       if (err.statusText == 'Unauthorized') { 
        ShowMessage('error', 'error', 'Please Login to Continue !!'); 
       } else { 
        ShowMessage('error', 'error', 'Error !!'); 
       } 
      } 
     }); 

Antwort

0

Sie müssen disbale Taste auf beforeSubmit einreichen und und ermöglichen es auf Erfolg oder Fehler. Lassen Sie sagen, Ihre Taste-ID besteht, erfolgt ‚Gegen Entry-Formular einreichen-btn‘

$('#counter-entry-form').ajaxForm({ 
    beforeSubmit: function() { 
    $('counter-entry-form-submit-btn').attr('disabled','disabled'); 
    // your code is here 
    }, 
    success: function() { 
    $('#counter-entry-form-submit-btn').removeAttr('disabled'); 
    // your code is here 
    }, 
    error: function() { 
    $('#counter-entry-form-submit-btn').removeAttr('disabled'); 
    // your code is here 
    } 
}); 
+0

Ich habe bereits gleiche Sache in meinem Code enthalten, der –

+0

ahh nicht funktioniert, dann ist das Button-Link oder Eingabe-Taste-Tag? –

Verwandte Themen