Answer the question
In order to leave comments, you need to log in
How to update 2 pjax objects with one request?
I have two grid tables on one page, each wrapped in its own PJAX with its own id. It is necessary that there would be an auto-update every n seconds. But can't get it to work right
<?php Pjax::begin([
'id' => 'select_pjax'
])?>
<?= GridView::widget([
'dataProvider' => $dataProviderTemp,
'columns' => [
......]])
<?php
$this->registerJs(
'$("document").ready(function(){
setTimeout(function(){
$.pjax.reload({container:"#select_pjax"}); //Reload GridView
},5000);
});'
);?>
<?php Pjax::end()?>
код всякий разный
<?php Pjax::begin([
'id' => 'save_pjax'
])?>
<?= GridView::widget([
'dataProvider' => $dataProviderTemp,
'columns' => [
......]])
<?php
$this->registerJs(
'$("document").ready(function(){
setTimeout(function(){
$.pjax.reload("#save_pjax"); //Reload GridView
},4000);
});'
);?>
<?php Pjax::end()?>
Answer the question
In order to leave comments, you need to log in
asynchronously they need to be executed$.pjax.reload({ container: #id, async:false });
https://github.com/yiisoft/jquery-pjax
Call in js to update containers by their id, for example:
$.pjax.reload('#pjax-container', options);
$.pjax.reload('#pjax-container2', options);
Option 1. Use normal ajax
$.ajax({
'success': function(data){
var targets = [
'#container1',
'#container2'
];
$.each(targets, function (ind, t) {
$(t).html($(data).find(t).html());
});
}
});
$.pjax.reload({container: "#container1", async:false});
$.pjax.reload({container: "#container2", async:false});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question