I have a View with table and a jQuery tablesorter plugin. It works very well. But, when I try to insert the table and tablesorter into the PartialView and paste this PartialView into the View page with Ajax, tablesorter does not work.
In partial view jquery does not work. The plugin is not called.
My controller code:
public ActionResult MyTable() {
My base code view
... <% using (Ajax.BeginForm("MyOrgsTable", new AjaxOptions { UpdateTargetId="MyTable", InsertionMode = InsertionMode.Replace})) { %> <p> Name: <%=Html.TextBox("search_org", ViewData["searchName"])%> <input type="submit" value="" /> </p> <% } %> <div id="MyTable"> </div> ...
My partial view code:
<script type="text/javascript" id="js"> $(document).ready(function() { </script> <table cellspacing="1" class="tablesorter"> <thead> <tr> ... </tr> </thead> <tbody> <% foreach ( var item in Model ) { %> // some table rows <% } %> </tbody> </table>
My main page title:
<script type="text/javascript" src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>"></script> <script type="text/javascript" src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>"></script> <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery-1.3.2.js") %>"></script> <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.tablesorter.js") %>"></script> <script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.tablesorter.pager.js") %>"></script>
Michael
source share