我编写ASP.NET应用程序,我想使用jQuery DataTables。ASP.NET jQuery不能从子目录工作
在母版页(这是不是在根目录)我包括在后面的代码脚本:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ScriptManagerSM.Scripts.Add(new ScriptReference(Page.ResolveUrl("~/js/jquery.min.js")));
ScriptManagerSM.Scripts.Add(new ScriptReference(Page.ResolveUrl("~/js/jquery-ui.min.js")));
ScriptManagerSM.Scripts.Add(new ScriptReference(Page.ResolveUrl("~/js/DataTables/jquery.dataTables.js")));
ScriptManagerSM.Scripts.Add(new ScriptReference(Page.ResolveUrl("~/js/setup.js")));
Page.Header.DataBind();
}
在页面我刚才纯HTML:
<table class="table display">
<thead>
<tr>
<th>Header</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr class="gradeX">
<td>Cell 1</td>
<td>Cell 2</td> </tr>
</tbody>
</table>
jQuery是由类选择在叫我的setup.js:
$(function() { var oTable = $('.table').dataTable({
"bJQueryUI": true,
"sScrollX": "",
"bSortClasses": false,
"aaSorting": [[0,'asc']],
"bAutoWidth": true,
"bInfo": true,
"sScrollY": "100%",
"sScrollX": "100%",
"bScrollCollapse": true,
"sPaginationType": "full_numbers",
"bRetrieve": true
});
});
一切正在放在根中的页面上工作。但在子文件夹中的页面jQuery没有被解雇。它看起来像一些路径的麻烦,但我看不到。
感谢您的帮助o..o
编辑:安装脚本添加
编辑2:新增调用的jQuery的
编辑3:加入$(函数(){上面的js代码(已经在我真正的代码存在的,只是在这里失踪
你应该使用Firefox的Firebug,看看如果您有任何JS错误。您还可以查看所有内容的加载顺序,以确保jQuery在其他脚本之前加载。最后,确保您通过$(document).ready({});检查DOM是否准备就绪。 – Zachary 2011-03-15 05:15:54