Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prev() method not working #134

Closed
annuh opened this issue May 3, 2014 · 8 comments
Closed

prev() method not working #134

annuh opened this issue May 3, 2014 · 8 comments

Comments

@annuh
Copy link

annuh commented May 3, 2014

Hello,
First of all thank you for this great plugin!

I am using the history plugin and would like to extend this plugin to scroll the page to the last clicked item. This works perfectly if the last clicked item is on the last loading page.
However, it is possible that this plugin has already loading (for example) page 4 while the users clicks an item on page 3.
To overcome this problem I would like to load the previous page automatically. The documentation states that the .prev() method (http://infiniteajaxscroll.com/docs/extension-history.html) should load the previous page, but this doesn't work for me.

I have also tried to execute the commands in the console:

$.ias().next(); // returns true;
$.ias().prev(); // returns undefined??

So far I have the following code. Could you tell me what I am doing wrong? :)
Thank you!

var ias = $.ias({
    container: '#cards-list',
    item: '.card-wrapper',
    pagination: '.pagination-bs',
    next: '.next'
});
ias.extension(new IASSpinnerExtension({
    html: $('.cards-loading-container').html(),
}));
ias.extension(new IASTriggerExtension({
    offset: 5,
    html: $('.cards-more-block-container').html(),
}));
ias.extension(new IASPagingExtension());
ias.extension(new IASHistoryExtension()); // Previous button has class 'prev'
ias.on('ready', function () {
    var id = window.location.hash.substr(1);
    if (id) {
        // Check if card is visible on current page
        var element = 'li#card-' + id;
        if (!$(element).length) {
            ias.on('rendered', function (items) {
                scrollTo(element);
            });
            ias.prev(); // Load previous page; not working :(
        } else {
            scrollTo(element);
        }
    }
});
@fieg
Copy link
Member

fieg commented May 5, 2014

Looks like that should work. I'll look into it.

@fieg
Copy link
Member

fieg commented May 12, 2014

Hi, I looked into this and found out that the Trigger extension is blocking the loading of the previous page.

In a unit-test I disabled the extension and wrote a wanky workaround, but perhaps it can help you to come to a solution, see https://github.com/webcreate/infinite-ajax-scroll/blob/master/test/04-history-extension-test.js#L49-L60

@JrrMaster
Copy link

Hi, you can got this working: http://infiniteajaxscroll.com/examples/history/page4.html but how to implement like that way? There is no clear documentation about that.

@jnessier
Copy link

jnessier commented Jul 6, 2015

seems not to be fixed. The example code isnt working...

ias.on('ready', function () {
ias.prev();
});

After the user returns, I want every previous pages loaded. Oh, and trigger is active.

@andrewblake1
Copy link

Without trigger extension disabled, all previous pages load for me - unfortunately one at a time while scrolling is all I want.

@rentox
Copy link

rentox commented Aug 18, 2016

Without trigger extension disabled, all previous pages load for me - unfortunately one at a time while scrolling is all I want.

have you found a solution for this? i want to reload the prev content on scroll up.

as you say, if i disable the trigger extension the prev content is loading.

found a script under "#220", sry

@rentox
Copy link

rentox commented Aug 24, 2016

  <script type="text/javascript">
  var ias = $.ias({
      container:  ".ajax_container",
      item:       ".ajax_item",
      pagination: "#pagination",
      next:       ".next a"
    });
  ias.extension(new IASSpinnerExtension());
  ias.extension(new IASPagingExtension());
  ias.extension(new IASTriggerExtension({ offset: 100 }));
  ias.extension(new IASHistoryExtension({ prev: '.prev a' }));

  </script>

  <script>
  $(window).bind('mousewheel', function(event) {
        if (event.originalEvent.wheelDelta >= 0) {
            console.log('Scroll up');
            ias.on('ready', function () {
            ias.prev();
            });
        }
        else {
            console.log('Scroll down');
        }
    });
  </script>

any new workaround for the "ias.prev();" and the IASTriggerExtension?

@fieg
Copy link
Member

fieg commented Mar 2, 2020

I'm closing this issue because Infinite Ajax Scroll 2 reached end of life and is being superseded by v3.

Suggestions given in this issue are filled under: #466. If you have questions, feedback or want to contribute, please comment on the new issue.

@fieg fieg closed this as completed Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants