我在网页上有一个数据表实例,它有完整的数字分页。这包括第一个、前一个、下一个和最后一个按钮加上单独编号的按钮。
表中的每一行都有一个“编辑”链接。当我点击它时,我想要禁用分页工作。当我单击“取消”按钮时,我希望恢复分页功能。我可以很容易地完成第一部分,但是我不能恢复分页单击功能。这是我的密码:
function ghostPage(state)
{
// In this method, 'state' will be either true or false
// If it's true, remove the click handler
// If it's false, restore the click handler
if(state)
{
$('#displayTable_paginate').find('a').each(function(e){
$(this).off('click');
})
}
else
{
$('#displayTable_paginate').find('a').each(function(){
$(this).on('click');
})
}
}发布于 2015-12-09 23:18:27
如果要保存单击处理程序并在稍后还原,请尝试此操作。
function saveClickHander(){
var $this;
$('#displayTable_paginate').find('a').each(function(e){
$this = $(this);
$this.data().originalClick = $this.data("events")['click'][0].handler;
})
}
function ghostPage(state)
{
// In this method, 'state' will be either true or false
// If it's true, remove the click handler
// If it's false, restore the click handler
if(state)
{
$('#displayTable_paginate').find('a').each(function(e){
$(this).off('click');
})
}
else
{
var $this;
$('#displayTable_paginate').find('a').each(function(){
$this = $(this);
$this.on('click', $this.data().originalClick);
})
}
}https://stackoverflow.com/questions/34190269
复制相似问题