Reputation: 1813
I would like to implement a slideUp jQuery effect on LinkButton click and then do postback on page. The effect takes 600ms to accomplish. The problem I confront with is that before jQuery effect finishes page already does postback, so the jQuery script stops somewhere halfway. Is there any way to delay postback other then doing a manual postback?
Upvotes: 1
Views: 1366
Reputation: 35514
You can block the PostBack event with return false
. Then invoke the PostBack of the button manually by calling __doPostBack
with the correct LinkButton name by using it's UniqueID
.
<script type="text/javascript">
function myFunction() {
//do stuff
setTimeout(function () { delayedPostBack(); }, 1000);
}
function delayedPostBack() {
__doPostBack('<%= LinkButton1.UniqueID %>', '');
}
</script>
<asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="myFunction(); return false;" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>
Upvotes: 0
Reputation: 18941
It is possible to provide a function to slideup which will only execute when the sliding is done:
formDiv.slideUp('normal', function () {
$(form).submit();
});
Upvotes: 3
Reputation: 337560
You can put the call to load/reload the page in the callback function of the slideUp
animation.
Something like:
$("#myElement").click(function() {
$("#otherElement").slideUp(600, function() {
// $("#form").submit(); // or
// window.location.assign("mypage.aspx");
});
})
If you could post your code I can show you in more detail.
Upvotes: 0