jquery + ASP.NET 延迟回发

发布于 2024-12-19 17:55:17 字数 151 浏览 2 评论 0原文

我想在 LinkBut​​ton 单击上实现 SlideUp jQuery 效果,然后在页面上进行回发。该效果需要 600ms 才能完成。我遇到的问题是,在 jQuery 效果完成之前,页面已经进行了回发,因此 jQuery 脚本在中途停止。除了手动回发之外,还有什么方法可以延迟回发吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜深人未静 2024-12-26 17:55:17

可以为slideup提供一个函数,该函数仅在滑动完成时执行:

formDiv.slideUp('normal', function () {
    $(form).submit();
  });

It is possible to provide a function to slideup which will only execute when the sliding is done:

formDiv.slideUp('normal', function () {
    $(form).submit();
  });
梦毁影碎の 2024-12-26 17:55:17

您可以将加载/重新加载页面的调用放在 slideUp 动画的回调函数中。

例如:

$("#myElement").click(function() {
    $("#otherElement").slideUp(600, function() {
        // $("#form").submit(); // or
        // window.location.assign("mypage.aspx");
    });
})

如果您可以发布您的代码,我可以向您展示更详细的信息。

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.

贩梦商人 2024-12-26 17:55:17

您可以通过 return false 阻止 PostBack 事件。然后通过使用正确的 LinkBut​​ton 名称(通过使用其 UniqueID)调用 __doPostBack 来手动调用按钮的 PostBack。

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文