yii2-scroll-pager
yii2-scroll-pager copied to clipboard
Previous pages are not loading after page refresh
when load more than one page, the url will change like "page=2", and now if we refresh, can only display the last page data ,and can't go back to first page,
Hi @xiaomalover.
Thank you for finding this issue. It's a serious one.
The problem is caused because of IAS extension "History" enabled by default. The best you can do is just to disable it by defining your pager as follows:
'pager' => [
'class' => ScrollPager::class,
'enabledExtensions' => [
ScrollPager::EXTENSION_TRIGGER,
ScrollPager::EXTENSION_SPINNER,
ScrollPager::EXTENSION_NONE_LEFT,
ScrollPager::EXTENSION_PAGING,
],
],
I'm not really sure that it will be a good idea to fix it in the extension code, as it may break existing deployments. But I will make necessary changes in the next major release.
Hi @kop.
Thank you very much.
Hi,
I tried defining my pager as the above code, it doesn't seem to fix the problem. My problem is similar to xiaomalover's. I have a page which uses the scroll pager, when a user clicks on a button, it posts data via ajax so the page doesn't refresh, I use jQuery to load the updated content in a container. For example: $('#student-side .container-inner').load(window.location.href + ' .user-opportunities', function () { ... }); When it reloads the content, the scroll pager doesn't work anymore, it either only displays the last page or the first page, and as you scroll to the end of that specific page, it doesn't load anymore (doesn't load any other pages that there is), can't go back or forward.
Please assist urgently.
Thank you. Kind regards.
@sandy0201, I don't really understand why you are using jQuery here? Scroll pager itself is loading everything via AJAX.
@kop, I'm using jQuery because by default, the button that users can click to apply or revoke an application refreshes the page, but we don't want it to refresh the page so we decided to use ajax to post the data and not refresh the page. Once a user apply for an application, an alert message shows but only when the page is refreshed, therefore we decided to reload the content of one part of the container only using jQuery, but we realised that this causes scroll pager not to work anymore. Is there a way to fix this?
@sandy0201 I got it now. Well, I don't really know what is causing plugin to stop working. Maybe it have different ID after new rendering. Or, maybe, it just loses JavaScript events attached. The best thing I can recommend is to use Pjax container for your needs and see does it work. Or, if you will find a reason why it gets broken after Ajax request, I will be happy to accept a PR.
@kop is there any way to re-attach the JavaScript events? Like is there any JavaScript function I can call to re-attach the Scroll Pager events to make it work?
@sandy0201 Well, you can try to reinit scroll plugin itself and remove old events. But it's better to ask such sort of questions in the original repo https://github.com/webcreate/infinite-ajax-scroll, as it's not related to this PHP package.
@kop Thank you for solution of history problem! Is there a plan how to fix it in future? ps I love your extension!
@indeveler, yes, it will be fixed soon. I'm having a vacation right now, but after return, I'm planning to release a new major version with some refactoring and fixes for the most annoying issues.
this one seems to be fixed i am using list view with the following setting for the scroller
'pager' => [
'class' => ScrollPager::className () ,
'container' => '#review-wrapper' ,
'item' => '.loader-class-review' ,
'paginationSelector' => '#review-wrapper>.pagination' ,
'next' => '#review-wrapper .pagination li.next a' ,
'historyPrev' => '#review-wrapper .pagination li.prev>a' ,
'noneLeftText' => 'No more Listings to display.' ,
'noneLeftTemplate' => '<div class="no-more col-sm-12"><span>{text}</span></div>' ,
'triggerText' => 'Load More Reviews' ,
'triggerTemplate' => '<div class="load-more"><a href="javascript:void(0)"><i class="zmdi zmdi-refresh-alt"></i> {text}</a></div>' ,
] ,
i am able to load the previous buttons after refreshing the page by going to the last record and even both next and previous if in the middle of the pagination
I need to changing address bar after scroll. if i disabled HISTORY address bar does not changing. if i enabled HISTORY address bar changing but previos data does not showing. How can i fix this ?