dotnetnoob
dotnetnoob

Reputation: 11330

jquery delay does not work as expected

I have the following function:

function sliderStop(id, value) {

    $(this).find('.ui-slider-tooltip').delay(500).fadeOut().delay(500);

    $('#' + id).val(value);
    __doPostBack(id, '');
}

I'm using the jquery ui-slider - this is the function called via the stop event.

I'm creating a postback for the control which works fine, but I want to fade the out tooltip out before calling the postback. The delay works on its own but doesn't seem to work when I add the postback code - I'm guessing it just posts back straight away I don't see the fade out.

If I remove the postback code, I can see the delay.

Any ideas how this might be fixed?

Thanks in advance.

Upvotes: 0

Views: 38

Answers (1)

tymeJV
tymeJV

Reputation: 104775

Use the callback of the fadeOut to wait for it to complete:

$(this).find('.ui-slider-tooltip').delay(500).fadeOut(function() {
    $('#' + id).val(value);
    __doPostBack(id, '');
});

Upvotes: 3

Related Questions