Team:ETH Zurich/labblog/buttons

From 2014.igem.org

(Difference between revisions)
Line 19: Line 19:
$(document).ready(function() {
$(document).ready(function() {
     $('.link-sort-list').click(function(e) {
     $('.link-sort-list').click(function(e) {
-
        var $sort = this;
+
$("#sort-list article").sort(function (a, b) {
-
        var $list = $('#sort-list');
+
    return parseInt(a.id) > parseInt(b.id);
-
        var $listLi = $('article',$list);
+
}).each(function(){
-
        $listLi.sort(function(a, b){
+
    var elem = $(this);
-
            var keyA = $(a).attr('date');
+
    elem.remove();
-
            var keyB = $(b).attr('date');
+
    $(elem).appendTo("#sort-list");
-
            if($($sort).hasClass('asc')){
+
})
-
                return (keyA > keyB) ? 1 : 0;
+
-
            } else {
+
-
                return (keyA < keyB) ? 1 : 0;
+
-
            }
+
-
        });
+
-
        $.each($listLi, function(index, row){
+
-
            $list.append(row);
+
-
        });
+
         e.preventDefault();
         e.preventDefault();
     });
     });

Revision as of 16:37, 28 August 2014

View all Lab Weekly Meetings Modeling
Oldest Newest