Post Arguments by Yii CListView

So, I have a pagination setting for one of my Yii projects and achieved the desired result using CListView . For security and readability, I configured the actionParams function only to display the $ _ POST parameters .

Now my problem is that when I click on any of my sorted fields or page links, it is actually GET . How do I change it to POST ?

+3
source share
1 answer

I am not tying it if it satisfies your needs, but you can manually activate ajax updates via JavaScript using $.fn.yiiListView.update('list-id',{type: 'POST'});. In the second argument you can also send data and other parameters ajax, for example $.fn.yiiListView.update('list-id',{type: 'POST',data:{ex_var: 'TEST'}});.

But for this you will have to bind the above click event of your pager.

Another solution is to edit jquery.yiilistview.js (you can find it in framework / zii / widgets / assets / listview). Go to line 82, where the update function is located, and edit its parameters, for example:

options = $.extend({
type: 'GET', //<- change this to POST
url: $.fn.yiiListView.getUrl(id),
    ...

});

You will also need to update the folder with your resources. But keep in mind that this will change the behavior of all your CListViews :)

Sincerely.

+3
source

All Articles