jQuery DataTable在asp.net mvc中无法工作4 [英] jQuery DataTable not working in asp.net mvc 4

查看:68
本文介绍了jQuery DataTable在asp.net mvc中无法工作4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试各种方式将jQuery DataTables插入到我的mvc应用程序中。阅读 http://datatables.net/blog/Microsoft_CDN 后,我决定使用Microsoft的CDN可能是最简单的方法是让DataTable启动并运行。



我将博客示例中找到的确切代码复制并粘贴到Index.vbhtml中,但我得到$(#example)。dataTable不是函数 。我也尝试使用DataTable调试器,但在我的页面上找不到任何DataTable。



因为我是一个ASP.net noob,我没有发现任何类似的问题,我觉得这个问题是简单的,我只是忽略。所以我提前道歉,如果这是一个可笑的问题,但任何帮助都不胜感激。

解决方案

我怀疑与不同的冲突jquery版本。 CDN上的版本和您的MVC网站中捆绑的jQuery的版本可能是冲突的。



查看您的/Views/Shared/_Layout.vbhtml(或_Layout.cshtml对于C#):

  @ Scripts.Render(〜/ bundles / jquery)

注释出来,再试一次,如果它工作,那么这是一个冲突。


I've been trying various ways to plug in jQuery DataTables to my mvc app. After reading http://datatables.net/blog/Microsoft_CDN, I decided that using Microsoft's CDN might be the easiest approach to just get a DataTable up and running.

I copied and pasted the exact code found in the blogs example into Index.vbhtml, but I get "$("#example").dataTable is not a function". I also tried using the DataTable debugger but it does not find any DataTables on my page.

Because I'm an ASP.net noob and I haven't found any similar problems anywhere, I feel that the problem is something simple that I'm just overlooking. So I apologize in advance if this is a ridiculous question, but any help is much appreciated.

解决方案

I suspect a conflict with different versions of jquery. The version on the CDN and the version of jquery bundled in your MVC site could be conflicting.

Look in your /Views/Shared/_Layout.vbhtml (or _Layout.cshtml for C#) for this line:

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

Comment it out and try again, if it works then it was a conflict.

这篇关于jQuery DataTable在asp.net mvc中无法工作4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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