【问题标题】:jquery tablesorter changing pagejquery tablesorter更改页面
【发布时间】:2022-01-24 04:20:30
【问题描述】:

按照此链接上的教程https://mottie.github.io/tablesorter/beta-testing/example-pager-custom-controls.html#

链接标签本身为空时,示例如何改变页面(点击页码)?

 link           : '<a href="#">{page}</a>', 

我的上一个和下一个按钮可以工作,但正如预期的那样,页码不起作用。我想知道在示例中,页码如何工作?

【问题讨论】:

    标签: jquery tablesorter


    【解决方案1】:

    从您的解释看来,您的链接缺少data-page 属性。检查这是否会对您有所帮助:

    <a href="#" data-page="10">10</a>
    

    data-page内需要传递动态页数

    【讨论】:

      【解决方案2】:

      问题是下面的函数(在 JQuery 中,pager-custom-controls.js)应该触发 onclick 事件,但由于我仍然不知道的任何原因而没有被触发。

      // pager-control setup
              $pager.on('click', options.currentPage, function() {
                  focusOnPager = true;
                  var $el = $(this);
                  $el
                      .addClass(options.currentClass)
                      .siblings()
                      .removeClass(options.currentClass);
                  $table.trigger('pageSet', $el.attr('data-page'));
                  return false;
              });
      

      作为一种解决方法,我在 (a) 标记中添加了一个自定义 onclick 函数,并将上面的代码添加到我的自定义 onclick 函数中。

      例子:

       link           : '<a href="#" onclick="({page});">{page}</a>', 
      
      function onclick(page) {
        var $el = $('#tableID').find('a[data-page]="' + page + '"');
        $el
          .addClass('current')
          .siblings()
          .removeClass('current');
        $('#tableID').trigger('pageSet', $el.attr('data-page'));
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多