yii2-scroll-pager icon indicating copy to clipboard operation
yii2-scroll-pager copied to clipboard

Previous pages are not loading after page refresh

Open xiaomalover opened this issue 9 years ago • 12 comments

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,

xiaomalover avatar Sep 26 '15 12:09 xiaomalover

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.

kop avatar Sep 29 '15 20:09 kop

Hi @kop.

Thank you very much.

xiaomalover avatar Sep 30 '15 03:09 xiaomalover

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 avatar Oct 19 '15 12:10 sandy0201

@sandy0201, I don't really understand why you are using jQuery here? Scroll pager itself is loading everything via AJAX.

kop avatar Oct 19 '15 12:10 kop

@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 avatar Oct 19 '15 12:10 sandy0201

@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 avatar Oct 19 '15 12:10 kop

@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 avatar Oct 19 '15 14:10 sandy0201

@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 avatar Oct 19 '15 14:10 kop

@kop Thank you for solution of history problem! Is there a plan how to fix it in future? ps I love your extension!

neochar avatar Jul 16 '16 19:07 neochar

@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.

kop avatar Jul 16 '16 20:07 kop

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

omer-sds avatar Jul 20 '17 20:07 omer-sds

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 ?

bilginnet avatar Dec 05 '17 12:12 bilginnet