var insertPrivilegeB=
{
execute:function()
{
$.ajax
({
url: "/SSH/ajaxGetPrivilegeBAction",
type:"POST",
dataType:"json",
success:function(ajaxData)
{
var map=getPrivilegeBMap(ajaxData);
/**这里绑定了事件,调用下面的reflesh时候alert("hh")将被调用两次*/
$("#privilegeManage").off("click",".open_or_close_privilegeB")
.on("click",".open_or_close_privilegeB",function (event)
{
alert("hh");
insertPrivilegeB.openOrClosePrivilegeB($(this),map);
});
},
error:function(data)
{
alert("数据异常!");
}
});
}
};
var reflesh=function()
{
insertPrivilegeB.execute();
};
两个方法的运行:刚刚开始直接运行insertPrivilegeB.execute();运行正常。
alert("hh")只执行一次。当点击刷新按钮则执行reflesh,此时alert执行两次,
说明事件重复绑定了,但是这该怎么解决?是我的代码有问题?