Hi, i’m using the pjax widget in order to load views when the user clicks on a link. I’m using the linkSelector option in my parent pjax widget to be able to do it. Something like this:
<?php Pjax::begin(['enablePushState' => false, 'id' => 'vinculo2', 'linkSelector' => 'a', 'timeout' => 8000, 'scrollTo' => 0, 'clientOptions' => ['skipOuterContainers' => true], 'options' => ['container' => '#contenedor-inicial']); ?>
<?php Pjax::end(); ?>
In the loaded views (most of them), I have a child pjax widget to control some gridviews, like this:
<?php Pjax::begin(['id' => 'listapersonasSocio', 'enablePushState' => false, 'timeout' => 5000, 'clientOptions' => ['skipOuterContainers' => true]]) ?>
<?= Gridview::widget([
'dataProvider' => $dataProvider,
// 'filterModel' => $searchModel,
'columns' => [
...
...
],
]); ?>
<?php Pjax::end() ?>
After I submit the form with data related to this gridview, I would like to reload the gridview with the new values, so i tried to use $.pjax.reload({container: ‘#listapersonasSocio’}); inside an AJAX call that submits the form. The AJAX call looks like this:
$('body').on('beforeSubmit', 'form#ingresar-sociop', function(e){
var formsp = $(this);
console.log(formsp.serialize());
$.post(
formsp.attr('action'),
formsp.serialize()
)
.done(function(result){
console.log(result);
if(result == 1){
$(formsp).trigger("reset");
$.pjax.reload({container: '#listapersonasSocio'});
}
else{
$('#message').html(result);
}
}).fail(function(){
console.log('Error de servidor');
});
return false;
});
But this causes the parent pjax widget to reload, so the whole page reloads and a “blank” page appears, since that’s where the parent pjax is located (just a blank view where i load all the content). I tried to use skipOuterContainers option to accomplish what i wanted, but it didn’t work.
Any help would be greatly appreciated, regards.