enter image description here enter image description here我是MVC的新手。我正在尝试使用DataTables JQuery脚本修改表。我能够从NPM安装数据表包。我在App_Start中修改了我的捆绑包;我还修改了Layout.cshtml文件,使其与App_Start文件夹中的好友同步。 事情是,当我修改我的表以使用Datable lib呈现时,它没有。该页面仍呈现旧的未格式化表。任何机构都可以在我哪里出错的任何想法方面帮助我?
我将附加我的bundles_config和视图(索引和布局)
请帮助。谢谢
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@*@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")*@
@Scripts.Render("~/bundles/lib")
@RenderSection("scripts", required: false)
</body>
</html>
--above is my Layout.cshtml
above is an excerpt from my index view showing my table with an id(students).
</table>
@section scripts
{
<script>
$(document).ready(function () {
$("#students").DataTable();
$("#students").on("click", ".js-delete", function () {
var button = $(this);
bootbox.confirm("are you sure you want to delete this customer?", function (result) {
if (result) {
$.ajax({
url: "/Students/delete/" + button.attr("data-student-id"),
method: "delete",
success: function () {
button.Parent("tr").remove();
}
});
}
});
});
});
</script>
}
using System.Web;
using System.Web.Optimization;
namespace ContosoSite
{
public class BundleConfig
{
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/lib").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/bootbox.js",
"~/Scripts/jquery-{version}.js",
"~/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 https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/datatables/css/datatables.bootstrap.css",
"~/Content/site.css"));
}
}
}
above is my BundleConfig file