Yii implements ajax sorting of sort

Source: Internet
Author: User
Through firebug, we found that every time we click the sort button generated by CSort, two sort classes (descasc) will be attached to the URL of links ), so we can use these two classes for sorting to achieve AJAX refresh and add arrows with different points. The effect is as follows:

Through firebug, we found that every time we click the sort button generated by CSort, two sort classes (desc asc) will be attached to the URL of links ), so we can use these two classes for sorting to achieve AJAX refresh and add arrows with different points. The effect is as follows:


First, we add the CSS control function of DESC to CLSS to control the arrow.


?
1234 . Sort. desc {padding: 0 10px 0px 10px; background: url (/images/sort_black.gif) no-repeat; background-position: 100%-20px;

ASC CSS


?
12345 . Sort. asc {padding: 0 10px 0px 10px; background: url (/images/sort_black.gif) no-repeat; background-position: 100% 4px ;}
OK. when we click it, the arrow will achieve the sorting effect.

AJAX processing

Load the extension library I wrote. of course, the following code snippets are only added for this implementation, and this extension code is scalable, including page turning


?
123456789101112 ; (Function ($) {$. fn. ajaxUpdate = function (id, url) {varoption = $. extend ({type: 'GET', url: url, success: function (data) {$ ('#' + id ). replaceWith ($ ('#' + id, data )). serialize () ;}}, option ||{}); $. ajax (option) ;}} (jQuery );
Insert the following AJAX submission event on the page

Parameter description

1. ID is the list you want to refresh. the list must contain this DIV, including paging.

2. the url is your controller address.


?
1234 $ ('. Sort '). live ('click', function () {$. fn. ajaxUpdate ('data', $ (this ). attr ('href '); returnfalse ;});
OK. the sorting and refresh are completed.


For original content reprinted, please indicate the source!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.