dev-master
9999999-devYii2 extension for infinite-scroll jQuery plugin
MIT
The Requires
- yiisoft/yii2 *
- bower-asset/jquery-infinite-scroll 2.*
by Alexander Stepanov
plugin yii2 jquery widget infinite-scroll
Yii2 extension for infinite-scroll jQuery plugin
Yii2 extension for infinite-scroll jQuery plugin, providing scrolling functionality for widgets such as ListView
.
It renders a hyperlink that leads to subsequent page of a target and registers
infinite-scroll jQuery plugin which uses javascript to fetch and append content for subsequent pages,
gracefully degrading to complete page reload when javascript is disabled., (*1)
Several behaviours allowing to customize scroll behavior are provided out of the box, including twitter-style manual trigger, local scroll in overflow div, masonry integration and others., (*2)
At the moment this extention only supports v2.x of infinite-scroll plugin., (*3)
Add extension to your composer.json
and update your dependencies as usual, e.g. by running composer update
, (*4)
{ "require": { "nirvana-msu/yii2-infinite-scroll": "1.0.*@dev" } }
In addition to most of the properties that LinkPager
provides, this widget also allows you to configure:, (*5)
Plugin works by appending fetched items to the end of parent container, so it is required
to configure layout
property of parent ListView
widget, wrapping {items}
into e.g. div
container with some class (to be used as a selector).
It is possible to configure all selectors that widget initializes plugin with to fit your project requirements, but it general it is enough to
set itemCssClass
(class of that wrapping tag that we created) and widgetId
(which would ensure multiple plugins on the same page would not conflict)., (*6)
So the minimal required configuration would look like this:, (*7)
echo ListView::widget([ ... 'id' => 'my-listview-id', 'layout' => "{summary}\n<div class=\"items\">{items}</div>\n{pager}", 'pager' => [ 'class' => InfiniteScrollPager::className(), 'widgetId' => 'my-listview-id', 'itemsCssClass' => 'items', ], ]);
An example illustrating how to customize some widget / plugin options:, (*8)
echo ListView::widget([ ... 'id' => 'my-listview-id', 'layout' => "{summary}\n<div class=\"items\">{items}</div>\n{pager}", 'pager' => [ 'class' => InfiniteScrollPager::className(), 'widgetId' => 'my-listview-id', 'itemsCssClass' => 'items', 'contentLoadedCallback' => 'afterAjaxListViewUpdate', 'nextPageLabel' => 'Load more items', 'linkOptions' => [ 'class' => 'btn btn-lg btn-block', ], 'pluginOptions' => [ 'loading' => [ 'msgText' => "<em>Loading next set of items...</em>", 'finishedMsg' => "<em>No more items to load</em>", ], 'behavior' => InfiniteScrollPager::BEHAVIOR_TWITTER, ], ], ]);
Extension is released under MIT license, same as underlying jQuery plugin., (*9)
Yii2 extension for infinite-scroll jQuery plugin
MIT
plugin yii2 jquery widget infinite-scroll