首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >移除和还原数据,分页,单击功能

移除和还原数据,分页,单击功能
EN

Stack Overflow用户
提问于 2015-12-09 22:31:38
回答 1查看 668关注 0票数 0

我在网页上有一个数据表实例,它有完整的数字分页。这包括第一个、前一个、下一个和最后一个按钮加上单独编号的按钮。

表中的每一行都有一个“编辑”链接。当我点击它时,我想要禁用分页工作。当我单击“取消”按钮时,我希望恢复分页功能。我可以很容易地完成第一部分,但是我不能恢复分页单击功能。这是我的密码:

代码语言:javascript
复制
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');
        })
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-09 23:18:27

如果要保存单击处理程序并在稍后还原,请尝试此操作。

代码语言:javascript
复制
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);
        })
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34190269

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档