MVC 4剃刀对象不支持属性或方法“的dataTable” [英] MVC 4 Razor Object doesn't support property or method 'dataTable'

查看:954
本文介绍了MVC 4剃刀对象不支持属性或方法“的dataTable”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是小白到MVC,jQuery和数据表。我收到了微软的Visual Studio警告对话框时,我打F5生成并打开该网站在当地的发展/调试:

I'm a noob to MVC, jquery and DataTables. I get a Microsoft Visual Studio warning dialog when I hit F5 to build and bring up the site locally for development/debug:

JavaScript的运行时错误:对象不支持属性或方法的dataTable

JavaScript runtime error: Object doesn't support property or method 'dataTable'

我使用VS 2012与MVC 4项目。我用的NuGet包管理器为我解决了安装\\更新的jQuery 1.8.3和1.9.4 jquery.datatables。这是我的看法Index.cshtml code:

I'm using VS 2012 with an MVC 4 project. I used the NuGet Package manager for my solution to install\update jQuery 1.8.3 and jquery.datatables 1.9.4. Here's my Index.cshtml view code:

<script src="@Url.Content("~/Scripts/jquery-1.8.3.js")" type="text/javascript">     </script>
<script src="@Url.Content("~/Scripts/DataTables-1.9.4/media/js/jquery.dataTables.js")" type="text/javascript"></script>


<script>
 $(document).ready(function () {
     $('#table_id').dataTable({
    });
});
</script>


<table id="table_id" class="display">
<thead>
    <tr>
        <th>Column 1</th>
        <th>Column 2</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Row 1 Data 1</td>
        <td>Row 1 Data 2</td>
    </tr>
    <tr>
        <td>Row 2 Data 1</td>
        <td>Row 2 Data 2</td>
    </tr>
</tbody>
</table>

这似乎是一个参考的问题,但没有我尝试解决这个问题!

It seems like a referencing problem, but nothing I've tried resolves the problem!

我已经通过博客搜索,但无法找到答案,或者了解需要改变什么。一个直接的答案会是极大的AP preciated!

I've searched through the blogs, but can't find the answer, or perhaps understand what needs to changed. A direct answer would be greatly appreciated!

谢谢!

推荐答案

我想你可能有一个试评这些行了:

I think you may have a try to comment these lines out:

@ Scripts.Render(〜/包/ jQuery的)

@Scripts.Render("~/bundles/jquery")

@RenderSection(脚本,必需:false)

@RenderSection("scripts", required: false)

,它们在_Layout.cshtml页的结束

which are at the end of "_Layout.cshtml" page.

希望这是有道理的。

这篇关于MVC 4剃刀对象不支持属性或方法“的dataTable”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆