【问题标题】:Out of stack space jquery (dataTables)堆栈空间不足的jQuery(dataTables)
【发布时间】: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


    【解决方案1】:

    这个函数

    $.fn.dataTable = function ( opts ) {
        return $(this).dataTable( opts ).api();
    };
    

    好像总是调用自己,会导致无限递归,会导致栈溢出(out of stack space)错误。

    【讨论】:

    • 嗯,我删除了 *.js 然后重新添加了它。现在给我一个不同的问题。我会尝试找出它在哪里 - 到目前为止看起来像是一个配置问题。不过感谢您的建议。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 2021-07-12
    • 2015-03-31
    • 2017-11-14
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多