Skip to content Skip to sidebar Skip to footer

Perform An Action After Trigger('click') Finishes Firing?

I manage a SharePoint site and have limited access to the underlying code; I can, however, manipulate things after the page loads via JavaScript. Have been using jQuery and SPServ

Solution 1:

Yes, just have your click handler return a deferred object and use it to decide when to redirect.

$("#the_save_button").click(function(e){
    e.preventDefault();
    return $.ajax({...});
});

Now you can do this:

$("#my_custom_save_button").click(function() {
    // do some custom stuff first
    $('#the_save_button').triggerHandler('click').done(function(){
        window.location.href = "/my/new/url.aspx";
    });

});

Note: using triggerHandler instead of trigger in this case is important, triggerHandler allows you to use the returned jqXHR object.


Post a Comment for "Perform An Action After Trigger('click') Finishes Firing?"