简体   繁体   中英

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.

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>

    }

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