st3ph / jquery.easyPaginate

jQuery plugin to paginate anything with cool effect (or not)
MIT License
45 stars 74 forks source link

Change ElementsPerPage on windows rezize #13

Open msarfernandez opened 6 years ago

msarfernandez commented 6 years ago

Hi, I need to change de value of ElementsPerPage depending on the document's width. Thats because is a responsive page. This is my code: $(window).resize(function () { if ($(document).width() < 970) { $('#easyPaginate').easyPaginate({ paginateElement: 'section', elementsPerPage: 1, effect: 'default' }); } if ($(document).width() >= 970) { $('#easyPaginate').easyPaginate({ paginateElement: 'section', elementsPerPage: 4, effect: 'default' }); } });

When document is > 970 and y rezize it to <970, ElementsPerPage change and shows 1 in place of 4, but when I want to come back, I still have 1 element on page.

There is a better way to make it work? Thanks!!