简体   繁体   English

返回partialview后的asp.mvc调用javascript

[英]asp.mvc call javascript after partialview is returned

I realise I can solve the following problem by using AJAX. 我意识到我可以使用AJAX解决以下问题。 However, I didn't realise that a progress wheel would need to implemented so therefore I currently get results via an ActionResult method 但是,我没有意识到需要实现进度轮,因此目前我通过ActionResult方法获得结果

   @Html.Action("devExpressGridView")

And at the server... 在服务器上

  return PartialView("devExpressGridView", Object);

So the problem is I need to call some javascript once the partial view has been returned 所以问题是一旦返回部分视图,我需要调用一些javascript

I know I can call some javascript on a button press or whatever to start to show the progress bar so this isn't no problem, 我知道我可以在按钮按下时调用一些javascript或其他任何东西来显示进度条,所以这不是没有问题,

but once the results has been returned from the action method, I need to hide the progress wheel so the user knows the data retrieval has been done. 但是从action方法返回结果后,我需要隐藏进度轮,以便用户知道数据检索已完成。

I basically need to fire ssomething like 我基本上需要像

// Once the action method has been completed, fire this...

        function hideProgress() {
                spinner.fadeOut("fast");
                spinnerVisible = false;
        };

is there a way to do this without AJAX? 没有AJAX,有没有办法做到这一点?

Thanks 谢谢

You can add a $(document).ready in the partial view. 您可以在部分视图中添加$(document).ready。

<script type="text/javascript">
    $(document).ready(function () {
        //do something here
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM