更改选项并重新初始化 [英] Change option and reinitialize

查看:76
本文介绍了更改选项并重新初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 jscroll 作为无限滚动寻呼机。

I am using jscroll as an infinite scroll pager.

$j('.frontpage').jscroll({
    loadingHtml: '<div style="text-align: center;"><img width="50" src="ring-alt-1.gif" alt="Loading" /></div>',
    padding: 20,
    nextSelector: 'div.next a',
    contentSelector: '.latest-container',
    autoTrigger: true,
    autoTriggerUntil: 1
});

这是一个非常整洁的插件,它使用我项目的必备品 autoTriggerUntil
使用该方法,您可以限制内容自动加载的时间并显示分页的下一个按钮。

This is a pretty neat plugin and it uses the must-have for my project autoTriggerUntil. Using that method you can limit the times that the content loads automatic and show the pagination's "next" button.

我想要实现的是这个。

What I am trying to achieve is this.


  1. 用无限加载第一组帖子(实际上是第2页)。 (完成)

  2. 在第2页之后,显示全部加载按钮。 (完成)

  3. 1和2都工作,但我想要做的是:点击第2页的全部加载后,我想销毁限制器并返回直到最后的无限观点。

我基本上需要以某种方式重新初始化。在过去的几个小时里,我一直在搞乱间隔和其他不良做法而没有结果。

I basically need to reinitialize this somehow. I have been messing with intervals and other bad practices the last couple of hours with no results.

推荐答案

挖完后我出来了这个解决方案: -

After digging I came out with this solution:-

首先,你需要添加一个这样的回调函数: -

first, you need to add a callback function like this:-

$('.frontpage').jscroll({
    //your existing settings ,
    callback: function() {
      if ($('div.next a').is(":visible")) {
         $('.frontpage').jscroll.destroy();
         $('div.next a').off('click');
       }
    }
});

第二次 onclick 属性加载所有 a 标记(仅在加载所有 a 标记可见的页面中)

Second Add onclick attribute to the load All a tag (only in the page where the load all a tag is visible)

onclick="loadAllClick(event);"

并且处理函数应如下所示: -

and the handler function should be like this:-

  <script>
      var loadAllClick = function(e) {
           e.preventDefault();
           $('.frontpage').jscroll( //your settings 
                               );
          }
  </script>

这里是一个完全工作的plunker样本
希望这能回答你的问题

and Here is a fully working plunker sample Hope this answers your question

这篇关于更改选项并重新初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆