U
U
unwrecker2015-07-08 00:03:10
Yii
unwrecker, 2015-07-08 00:03:10

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

1 answer(s)
U
unwrecker, 2015-07-08
@unwrecker

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})
    })
  });
');

Where: filter_tree - widget id, #list - id of updated pjax block, service - GET parameter where the value is set.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question