我WebGrid
在我的项目中使用。当我在浏览器中检查我的代码(aspx
页面)时,我在控制台上发现了错误。它是:TypeError: $(...).parent(...).delegate is not a function
当我单击错误行时,它会显示以下代码:
$(function() {
$('table[data-swhgajax="true"],span[data-swhgajax="true"]').each(function() {
var self = $(this);
var containerId = '#' + self.data('swhgcontainer');
var callback = getFunction(self.data('swhgcallback'));
/*here comes the error*/
$(containerId).parent().delegate(containerId + ' a[data-swhglnk="true"]', 'click', function() {
$(containerId).swhgLoad($(this).attr('href'), containerId, callback);
return false;
});
})
});
主 ASPX 页面代码:
<%using (Html.BeginForm("Action", "Dashboard", FormMethod.Post)) { %>
<div id="MainDashboardDiv">
<div class="UpperLiveTiles">
<div id="RecentDiv">
<a href="../CRM/RecentCRMRequest">
<h4 class="RequestTitle">Recent Requests</h4>
</a>
<%Html.RenderAction("RecentRequests", Model); %>
</div><!--End of RecentDiv -->
<div id="PriorityDiv">
<a href="../CRM/HighPriorityCRMRequest">
<h4 class="RequestTitle">High Priority Requests</h4>
</a>
<%Html.RenderAction("PriorityRequests", Model); %>
</div><!--End of PriorityDiv -->
</div><!--End of UpperLiveTiles -->
</div><!--End of MainDashboardDiv -->
<%} %>
部分视图1 代码:
<%
var grid1var = new WebGrid(source: Model, defaultSort: "Id", fieldNamePrefix: "grid1", canSort: true, ajaxUpdateContainerId: "FirstDiv", canPage: true, rowsPerPage: 5);%>
<div id="FirstDiv">
<%=
grid1var.GetHtml(htmlAttributes: new { id = "grid1" }, tableStyle: "GridTable", headerStyle: "GridHeader",
columns: grid1var.Columns(
grid1var.Column(columnName: "Id", header: "ID", canSort: true),
grid1var.Column(columnName: "Requester_Name", header: "Employee", canSort: true),
grid1var.Column(columnName: "Estimated_Amount", header: "Amount", canSort: true),
grid1var.Column(columnName: "Date_Created", header: "Date", canSort: true, format: item => item.Date_Created.ToString("dd-MM-yyyy"))
))
%>
</div>
部分视图2代码:
<%
var grid2var = new WebGrid(source: Model, defaultSort: "Id", fieldNamePrefix: "grid2", canSort: true, ajaxUpdateContainerId: "SecondDiv", canPage: true, rowsPerPage: 5);%>
<div id="SecondDiv">
<%=
grid2var.GetHtml(htmlAttributes: new { id = "grid2" }, tableStyle: "GridTable", headerStyle: "GridHeader",
columns: grid2var.Columns(
grid2var.Column(columnName: "Id", header: "ID", canSort: true),
grid2var.Column(columnName: "Requester_Name", header: "Employee", canSort: true),
grid2var.Column(columnName: "Estimated_Amount", header: "Amount", canSort: true),
grid2var.Column(columnName: "Date_Created", header: "Date", canSort: true, format: item => item.Date_Created.ToString("dd-MM-yyyy"))
))
%>
</div>
我不知道这是什么类型的错误。
我终于发现了错误:
只是因为我在系统中使用的现成jquery菜单使用的是旧的jquery。它与新的 Jquery 版本冲突。我已删除该菜单,一切正常。