I'm trying to define two eventhandlers for the same form in two different places.
modalPlaceholder.on('submit', 'form', function(e){
var url = $(this).attr('action');
var data = $(this).serialize();
$.ajax({
// ajax stuff
});
e.preventDefault();
})
This one to send the form via ajax post.
$('body').on('submit', 'form', function(){
$(this).find('.hasPlaceholder').each(function() {
$(this).val('');
});
})
This one to zero form values that are just placeholders, so they dont get sent to the server as actual values.
For forms, that are not within modalPlaceholder, this works fine. But for forms that I want to send with ajax, the form gets serialized and sent before the zeroing happens.
Is there a way to define an order in which the eventhandlers get called? Help much appreciated.