Skip to content

Instantly share code, notes, and snippets.

@LANSELOT
Created August 14, 2016 18:00
Show Gist options
  • Save LANSELOT/d928bc303b8575f8a289ca017efac29f to your computer and use it in GitHub Desktop.
Save LANSELOT/d928bc303b8575f8a289ca017efac29f to your computer and use it in GitHub Desktop.
use yii\widgets\Pjax;
use yii\widgets\PjaxAsset;
PjaxAsset::register($this);
$this->registerJs(<<<JS
$(document).on('change', '#provider', function(e) {
$.pjax({
timeout: 4000,
url: $('#filter-form').attr('action'),
container: '#list-view',
fragment: '#list-view',
data: {provider: this.options[this.selectedIndex].value},
});
});
JS
, yii\web\View::POS_END);
<?=Html::beginForm(Url::current(), 'GET', ['id'=>'filter-form']);?>
<?=Html::activeDropDownList($model, 'provider', Provider::items(), ['id'=>'provider']); ?>
<?=Html::endForm(); ?>
<?php \yii\widgets\Pjax::begin(); ?>
<?= \yii\widgets\ListView::widget([.....]) ?>
<?php \yii\widgets\Pjax::end(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment