简体   繁体   中英

asp.mvc call javascript after partialview is returned

I realise I can solve the following problem by using AJAX. However, I didn't realise that a progress wheel would need to implemented so therefore I currently get results via an ActionResult method

   @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

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,

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.

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?

Thanks

You can add a $(document).ready in the partial view.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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