我试图在发送请求时在asp.net ajax BeginrequestHandler和EndRequestHandler事件中绑定$(document).click事件,应该调用unbind以使click事件不起作用。调用endRequestHandler时,应再次执行绑定。
function BeginRequestHandler(sender, args)
{
$(document).unbind("click");
$("#divUtility > :first-child").css({
'position':'absolute',
'left':'0px',
'right':'0px',
'width':'250px',
'height':'70px',
'background-color':'#EfEfEF'
});
}
function EndRequestHandler(sender, args)
{
$(document).bind("click",function(e){
if($(e.target).hasClass("UtilityClass"))
{
}
else
{
$('.popupstyle').hide();
}
});
}
其余的工作正常。但是,解开不起作用。
答案 0 :(得分:0)
要做的第一项任务是放一些
console.debug("your message")
在您的函数中
function BeginRequestHandler(sender, args)
以检查是否真的调用了回调。
其次,您应该在点击时使用命名空间,以避免在点击事件上删除所有事件处理程序(甚至不是你的)。使用
添加事件处理程序$(document).bind("click.myNameSpace", function(mouseEvent) {
// your code here
});
并使用
删除您的事件处理程序$(document).unbind("click.myNameSpace");