我使用pjax在yii2网格中使用常见搜索。我想要的是在keyup事件上激活pjax。默认它使用onchange事件或onsubmit事件。
的index.php
<div class="pull-right">
<?=$this->render('_search', array('model'=>$searchModel));?>
</div>
<?php Pjax::begin(['id' => 'assets','enablePushState' => false]); ?>
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
--Coloumns--
],
['class' => 'yii\grid\ActionColumn',
],
]);
?>
<?php Pjax::end(); ?>
_search.php
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
?>
<?php
$this->registerJs(
'$("document").ready(function(){
$("#search-form").on("pjax:end", function() {
$.pjax.reload({container:"#assets"});
});
});'
);
?>
<div class="assets-search">
<?php yii\widgets\Pjax::begin(['id' => 'search-form']) ?>
<?php $form = ActiveForm::begin([
'options' => ['data-pjax' => true ],
'action' => ['search'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'searchString') ?>
<?php ActiveForm::end(); ?>
<?php yii\widgets\Pjax::end() ?>
</div>
我需要做什么来实现onkeyup搜索而不是onsubmit或onchange事件。请引导我找到正确的解决方案或提供一些有用的链接。