2016-07-24 58 views
-1

这里是束配置

// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862 
    public static void RegisterBundles(BundleCollection bundles) 
    { 
     bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Scripts/jquery-{version}.js")); 

     bundles.Add(new ScriptBundle("~/bundles/datatable").Include(     
        "~/Scripts/DataTables/jquery.dataTables.js", 
        "~/Scripts/DataTables/dataTables.bootstrap.js"      
       )); 



     bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
        "~/Scripts/jquery.validate*")); 

     // Use the development version of Modernizr to develop with and learn from. Then, when you're 
     // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. 
     bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
        "~/Scripts/modernizr-*")); 

     bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
        "~/Scripts/bootstrap.js", 
        "~/Scripts/respond.js" 
       )); 

     bundles.Add(new StyleBundle("~/Content/css").Include(
        "~/Content/bootstrap.css", 
        "~/Content/DataTables/css/dataTables.bootstrap.css", 
        "~/Content/site.css" 
       )); 
    } 
} 

这里是_layout

@Scripts.Render("~/bundles/jquery") 
@Scripts.Render("~/bundles/datatable") 
@Scripts.Render("~/bundles/bootstrap") 
@RenderSection("scripts", required: false) 

这里是JavaScript

<script> 

$(document).ready(function() { 
    $("#productTable").DataTable(); 
}); 

请帮帮我。我只是不知道为什么我一直有这个错误。它似乎是引用Datatable库的问题。 在此先感谢

回答

0

请在您的视图中使用@section脚本。

@section scripts 
{ 
<script> 
    $(document).ready(function() { 
     $("#productTable").DataTable(); 
    }); 
</script> 
}