JQuery Sortable set item to an index programmatically

前端 未结 2 542
说谎
说谎 2020-12-18 02:18

I have a JQuery sortable (1.7.1 can change if necessary) list like so:

  • 1
2条回答
  •  有刺的猬
    2020-12-18 02:39

    This worked perfectly.

    Follow the steps and include this:

        $el.fadeOut(1000, function(){
            $el.insertAfter($el.next());
    
            $el.fadeIn(1000);
        });
    

    Like this (setting the id of the li tag of course):

    jQuery(".templateMoveUp").on("click", function(){   
        $el = jQuery("#" + $(this).attr("id") + "_logTemplate");
        $el.fadeOut(1000, function(){
            $el.insertBefore($el.prev());
            $el.fadeIn(1000);
        });
    });
    jQuery(".templateMoveDown").on("click", function(){ 
        $el = jQuery("#" + $(this).attr("id") + "_logTemplate");
        $el.fadeOut(1000, function(){
            $el.insertAfter($el.next());
            $el.fadeIn(1000);
        });
    });
    

提交回复
热议问题