【发布时间】:2015-05-21 19:07:48
【问题描述】:
在 VS2013 中第一次尝试一些 MVC,花了一些时间来运行一个基本的测试/演示。所以我想我会尝试让 dataTables 使用它。但是,在查看应用程序 index.cshtml 时,它不断抛出堆栈空间不足的错误(用 Chrome 和 IE8 测试)。我也尝试在其中创建一个空白来占位。
这是我的 bundleconfig.cs
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.10.2.js"));
_layout.cshtml
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
还有我自己的index.cshtml的相关部分
<table class="table" id="plist">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.1)</th>
<th>@Html.DisplayNameFor(model => model.2)</th>
<th>@Html.DisplayNameFor(model => model.3)</th>
<th>@Html.DisplayNameFor(model => model.4)</th>
<th>@Html.DisplayNameFor(model => model.5)</th>
<th>@Html.DisplayNameFor(model => model.6)</th>
<th>@Html.DisplayNameFor(model => model.7)</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.1)</td>
<td>@Html.DisplayFor(modelItem => item.2)</td>
<td>@Html.DisplayFor(modelItem => item.3)</td>
<td>@Html.DisplayFor(modelItem => item.4)</td>
<td>@Html.DisplayFor(modelItem => item.5)</td>
<td>@Html.DisplayFor(modelItem => item.6)</td>
<td>@Html.DisplayFor(modelItem => item.7)</td>
<td>@Html.ActionLink("Edit", "Edit", new { id=item.1 }) |
@Html.ActionLink("Details", "Details", new { id=item.1 }) |
@Html.ActionLink("Delete", "Delete", new { id=item.1 })
</td>
</tr>
}</tbody>
</table>
<link href="~/Content/jquery.dataTables.css" rel="stylesheet" />
<script src="~/Scripts/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf8">
$(document).ready(function() {$('#plist').dataTable();});
</script>
IE调试器在dataTables脚本文件这里抛出异常:
$.fn.dataTable = function ( opts ) {
return $(this).dataTable( opts ).api();
};
我知道这个问题很广泛,但是请检查一下有什么常见的问题吗?
【问题讨论】:
标签: c# jquery asp.net-mvc razor asp.net-mvc-5