简体   繁体   English

如何在使用ajax调用局部视图时在mvc 4中加载脚本

[英]How to load scripts in mvc 4 while using ajax call the partial view

Home page 主页

 <a data-ajax="true" data-ajax-begin="onBegin(&quot;/Organisation/SearchForStudent/&quot;)" data-ajax-complete="onComplete" data-ajax-mode="replace" data-ajax-update="#dvmain" href="/Organisation/SearchForStudent/"><i class="fa fa-search"></i><span class="nav-label">Search for Student</span></a>


    <div id="dvmain"></div>

partial view 局部视图

<div class="row wrapper border-bottom white-bg page-heading" id="MainHeaddivStaff">
    <div class="col-lg-10">
        <h2>Search for Staff</h2>
    </div>
    <div class="col-lg-2">
    </div>
</div>
<script src="../js/plugins/footable/footable.all.min.js"></script>
<script type="text/javascript">
    var staffid = 0;
    var BrnachIDforleave = 0;
    var foot = 0;
</script>

in home page only html tags of partial view are bind, but script are not bind. 在主页中,只有部分视图的html标签是绑定的,但脚本不绑定。

As far as I know all the script tags shall be included in the landing page (Home page in your case, if it is the landing page). 据我所知,所有脚本标签都应包含在登录页面中(如果是登录页面,则为主页)。

Try loading the script in the home page. 尝试在主页中加载脚本。

put them in partial page as 将它们放在部分页面中

     @section scripts {
    <script src="../js/plugins/footable/footable.all.min.js"></script>
<script type="text/javascript">
    var staffid = 0;
    var BrnachIDforleave = 0;
    var foot = 0;
</script>

    }

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

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