Answer the question
In order to leave comments, you need to log in
How to make paginator in yii2 work via POST?
There is a page with TreeViewInput, found results and a paginator under them. Everything is wrapped in pjax. Through GET it worked fine, but sometimes it didn’t go along the length. Changed to POST. But now the paginator stupidly resets all filters when switching between pages.
There is not a word about post in the documentation for the paginator. Well, this is really not the most correct option, but what to do?
Answer the question
In order to leave comments, you need to log in
However, it turned out that I didn't need it. Hooray!
The length of the GET request turned out to be too large due to a pjax bug (or feature) when manually calling pjax.reload - instead of replacing the parameter value, it was re-added to the end of the URL. It helped to use the “replace: false” option, which actually should be false by default anyway, and logically it should be translated to true, but it helped ...
Maybe the following code will come in handy for someone. This is an autosubmit for TreeViewInput::widget
$this->registerJs('
$("document").ready(function(){
$("#filter_tree").on("change", function() {
$.pjax.reload("#list", {
method: "GET",
data: {service:$(this).val()},
replace: false})
})
});
');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question