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!