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

Cannot use trigger('click') or click on pagination #452

Closed
oninross opened this issue Oct 20, 2016 · 5 comments
Closed

Cannot use trigger('click') or click on pagination #452

oninross opened this issue Oct 20, 2016 · 5 comments

Comments

@oninross
Copy link

Assigning click events on the pagination does not enable JavaScript to dynamically trigger the page. I am following one of the issues (javve/list.pagination.js#6) and applied it to my code and nothing happened.

Having that said, it still doesn't solve the issue of developers triggering the pagination using javascript

@iszlailorand
Copy link

i had the same problem, but i soleved it with dynamically assigned click events. Something like > $(where to check for dynamically created selector).on('click', 'dynamical selector', function(event) {your funny stuff here} ... have luck.

javve added a commit that referenced this issue Feb 4, 2017
@javve
Copy link
Owner

javve commented Feb 4, 2017

I'm not sure why you can't use trigger('click') (maybe the requires that the listener have been added by jQuery?), but in next version (see reference from commit) you can see with page and i each pagination link triggers. So instead if clicking them you can see the data attribute and do the change yourself via listObj.show(i, page), ref: http://listjs.com/api/#show

@javve javve closed this as completed Feb 4, 2017
@hitolonen
Copy link

@javve on pagination click we would need to scroll back to top/specific page element as clicking to another page doesn't do it by default. How can we achieve this?

@4loop-co
Copy link

4loop-co commented Nov 14, 2019

This should do it.

$(document).on('click', 'a.page', function() {
     $('html, body').animate({
         scrollTop: $('h1').offset().top
     }, 500);
 });

@Stolzenhain
Copy link

This should do it.

here's a variant without jQuery:

document.addEventListener( 'click', function( event ){
    if ( !event.target.matches( '.pagination [a|button]' ) ) { return; }
    // do scrolling here
} );

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