Answer the question
In order to leave comments, you need to log in
How to make all filters work in a group?
Good afternoon,
I'm doing just such a thing on the client, loadMore AND 3 filters) The
question is how to make them work together?
Deleal through ActiveDataProvider and jquery Here are
a couple of pieces of code)
Select
<?php $this->registerJS('
$("select").click(function(){
var param = $(\'meta[name=csrf-param]\').attr("content");
var token = $(\'meta[name=csrf-token]\').attr("content");
$.ajax({
type: "post",
data: {
"matches": $(this).val(),
param: token
},
success: function(data){
$(".list-view").append(data);
// if (page >= pageCount){ $(\'#js-load-more\').hide(); }
}
});
});
');
<?php $this->registerJS('
$('#js-load-more').click(function(){
$.ajax({
type: "post",
data: {
"page": page+1,
param: token
},
success: function(data){
page++;
loadingFlag = false;
$('#listView').append(data);
if (page >= pageCount){ $('#js-load-more').hide(); }
}
});
});
public function actionIndex(){
$query = User::find()->where(['rights' => new Expression('IFNULL(rights,0) | '.UserRightsEnum::BGO_PASS)]);
$this->processPageRequest('page');
$provider = new ActiveDataProvider([
'query' => $query,
'sort'=> ['defaultOrder' => ['id'=> \Yii::$app->request->post('matches') ? SORT_DESC : SORT_ASC]],
'pagination' => [
'pageSize' => 6,
'page' =>\Yii::$app->request->get('page'),
],
]);
if (\Yii::$app->request->isAjax){
return $this->renderPartial('_list', [
'dataProvider' => $provider,
]);
} else {
return $this->render('index', [
'dataProvider' => $provider,
]);
}
}
Answer the question
In order to leave comments, you need to log in
It's easier with pjax. But do not update the content, but add below.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question