Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reload multiple pjax

Tags:

yii2

pjax

i just want to know how to reload multiple pjax? this is my code

        $.pjax.reload({container:"#con_camp"});
        $.pjax.reload({container:"#con_camp1"});

but only the #con_camp1 is the one that will reload.

like image 731
joshua pogi 28 Avatar asked Aug 13 '15 10:08

joshua pogi 28


2 Answers

Unfortunately Pjax by design doesn't allow multiple requests. In order to do those you have to nullify xhr parameter in $.pjax.

Basically like this:

$.pjax.reload({container:"#con_camp"});
$.pjax.xhr = null;
$.pjax.reload({container:"#con_camp1"});
$.pjax.xhr = null; // so that some next pjax request wont cancel this reload.
like image 126
Alex Avatar answered Sep 26 '22 01:09

Alex


You could just do

$.pjax.reload({container: '#container_1'}).done(function () {
    $.pjax.reload({container: '#container_2'});
});
like image 37
Coz Avatar answered Sep 23 '22 01:09

Coz