在我的 MVC 项目中,我有这个编辑器模板。我无法在 IE 开发人员工具中调试它,因为它在弹出窗口中。我无法访问其他浏览器。所以我的 jquery 没有获取 url、employeeId 和 businessUnitId 的值。
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<SHP.Models.BusinessUnitSelected>" %>
<tr>
<td><%: Model.BusinessUnit.BusinessUnitName %></td>
<td>
<%: Html.CheckBoxFor(
x => x.Selected,
new RouteValueDictionary
{
{ "data-url", Url.Action("AddBusinessUnitForEmployee", "DataService") },
{ "data-employeeId", Model.EmployeeId },
{ "data-businessUnitId", Model.BusinessUnit.BusinessUnitId }
}
) %>
</td>
</tr>
<script type="text/javascript">
$(document).ready(function () {
$('tr input[type="checkbox"]').click(function () {
var elementId = $(this).attr('id');
alert("elementId = " + elementId);
var url = $(this).val('data-url');
alert("url = " + url);
var employeeId = $(this).val('data-employeeId');
alert("employeeId = " + employeeId);
var businessUnitId = $(this).val('data-businessUnitId');
alert("businessunitId = " + businessUnitId);
var selectedFlag = $(this).is(':checked');
alert("selectedFlag = " + selectedFlag);
dataService.saveSelection(
employeeId,
businessUnitId,
selectedFlag,
elementId,
SavedSetting,
url
);
});
});
</script>