Return to Snippet

Revision: 67077
at August 6, 2014 21:44 by dmkim


Initial Code
var form =jQuery('form[name="testform"]');     

 var events = form.data("events");  

 var previous_submit = events.submit[0]['handler'];

 form.unbind('submit', events.submit[0]);
              
           
form.bind('submit', function() {
       
                 if (previous_submit.call(this)==false)
                    return false;
               
             var data = {};
             jQuery(this).find('input[name],select[name],textarea[name]').each(
                    function(index, input) {
                           data[input.name] = input.value;
                        })
                       
                 $.when( 
                   $.ajax ( {
                     type : 'POST',
                     url  : location.protocol+'//'+location.hostname+location.pathname,
                     data: data,
                     success: onSuccess
                   }) 
                  ).done (function() {
                     console.log('form submitted');
                   })   
                 
        
          });

Initial URL

                                

Initial Description
Bind Submit form Event  handler after previously attached  handler

Initial Title
Bind Submit form Event  handler after previously attached  handler

Initial Tags

                                

Initial Language
jQuery