jQuery trigger custom event synchronously?

You, my friend, are looking for jQuery “when”.

http://api.jquery.com/jQuery.when/

To force anything to be synchronous, you can use something like this….

$.when($(this).trigger('custom-event')).done(function(){
    window.location.href="https://stackoverflow.com/questions/13338484/url";
});

Leave a Comment