Answer the question
In order to leave comments, you need to log in
Is it possible to update two blocks using Pjax?
Hello!
I am using Pjax widget in Yii2. On the product page there is a filter, as well as the results of applying the filter. Separately, the filter and separately the output of the results are wrapped in Pjax. Is it possible, when changing one block (filter), to update the data in both blocks with one request?
Thank you.
Answer the question
In order to leave comments, you need to log in
I'm not sure if it's possible with one request, but with one click it's possible for sure. Here are the docs on the script itself:
https://github.com/defunkt/jquery-pjax
Haven't tried it like this, but I think that there are 2 paths, or two containers that have the same linkSelector, or cling to the pjax:success event
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