Suddenly, pjax reload fails to reload the GridView. It instead refreshes the page and I have no idea why. Is it new thing with the recent Yii2 release?
Here is the code
$.pjax.reload({container:'#my-grid-view'});
To fix this issue, I set async to false (from stackoverflow) as follow:
You most likely have multiple pjax or pjax widget inside of another pjax. There really isn’t a fix just a bunch of work arounds. The async option is only used to update multiple at once.
I went and dug out this little gem as my workaround for a lot of these issues. You can just call pjaxReload(); and it will reload the most parent pjax if they are nested or it will reload all of them on the page. You can also tell it to reload specific ids by doing pjaxReload(‘my-grid-view’); or comma delimit them to add a few of them. Unfortunately it was minified, I spaced it properly but it still looks crazy.
pjaxReload = function(a) {
if (!a) var a = jQuery("[data-pjax-container]").map(function() {
var a = jQuery(this).attr("id");
if (1 !== jQuery("#" + a).parents("[data-pjax-container]").length) return a
}).get().join(",");
if (void 0 !== typeof a) {
var e = a.split(",");
1 === e.length ? jQuery.pjax.reload({
container: "#" + jQuery.trim(a)
}) : e.length > 1 && jQuery.each(e, function(a) {
"" !== e[a] && jQuery.pjax.reload({
container: "#" + jQuery.trim(e[a]),
async: !1
})
})
}
};