我有这个按钮点击事件:
$('#btnDelete').on('click', function(userId)
{
var treeView = $("#treeview").data("kendoTreeView");
$('#treeview').find('input:checkbox:checked').each(function()
{
var li = $(this).closest(".k-item")[0];
var notificationId = treeView.dataSource.getByUid(li.getAttribute('data-uid')).ID;
$.ajax(
{
url: '../api/notifications/deleteNotification?userId=' + userId + '¬ificationId=' + notificationId,
type: 'DELETE',
success: alert('Delete successful.'),
failure: alert('Delete failed.')
});
});
});
“userId”来自基本页面:
public class BasePage : System.Web.UI.Page, IRequiresSessionState
{
public int UserId
{
get
{
return T2Identity.UserId;
}
}
}
如何在按钮“btnDelete”的单击事件中将 userId 变量传递给我的 JavaScript 函数?