Delaying form submission via Javascript doesn't work in IE I have a form built for creating an instance of a custom entity. Upon submitting the form, I have a jquery script completing some actions on the page that need to execute before the form submits, so I attempt to stop the default event, perform those actions, and then resume the event as follows:

$('#submit').on('click', function(event){
    if (valid === true) {
        valid = false;
        return;
    }
    event.preventDefault();
    valid = true;
    //do some stuff
    $(this).trigger('click');
});


This works perfectly in Chrome, but unsurprisingly does not work in IE11. Through console logging I see that the re-click is fired, but the return line  simply does nothing, so the button click does not submit the form at all. I have tried some alternatives to $(this).trigger('click'); explained in a stackoverflow thread, but nothing is getting it to work.

The reason I'm creating a Drupal-specific thread about it is that I also tried  to skip re-firing entirely and just do a form submission like this:

$('#submit').on('click', function(event){
    event.preventDefault();
    //do some stuff
    $('form[data-drupal-selector="my-form-id"]').submit();
});


But this, for whatever reason, clears all of the data in any field collection items contained within the form.

Is there any feasible way to do what I'm trying to accomplish in Drupal that works in all modern browsers?
Try doing something like:

 $("form").submit( function () {
   //do something
   return true;
 }


Source