Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript select2 sortable

//CSS Must Include CSS
.sortable {
    list-style-type: none;
  
}

.select2-selection__rendered li.placeholder {
    width: 0;
    height: 0;
    border-bottom: 5px solid transparent !important;
    border-top: 5px solid green !important;
    border-left: 5px solid transparent !important;
    border-right: 5px solid transparent !important;
    max-width: 100%;
    overflow: hidden;
    /*Altered two below to make word wrap work */
    word-wrap: normal !important;
    white-space: normal;
    float: left;
}

$("#selectid").select2(opt);
("#selectid").parent().find(".select2-selection__rendered").sortable({
    containment: 'parent',
    onDrop: function ($item, container, _super) {
        var $clonedItem = $('<li/>').css({ height: 0 });
        $item.before($clonedItem);
        $clonedItem.animate({ 'height': $item.height() });
        $item.animate($clonedItem.position(), function () {
            $clonedItem.detach();
            _super($item, container);
        });                     

        $($("#selectid").parent().find("ul").find('.select2-selection__choice').get().reverse()).each(function () {
            var id = $(this).data('data').id;
            var option = $(this_val).find('option[value="' + id + '"]')[0];
            $("#selectid").prepend(option);
        });

        $("#selectid").trigger("change");
    }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular chartjs align legend left 
Javascript :: clock picker jquery 
Javascript :: javascript closure interview questions 
Javascript :: Alpine.js: button using @click function not working 
Javascript :: array 
Javascript :: flatlist react native keyextractor 
Javascript :: javascript date from string dd/mm/yyyy HH mm ss 
Javascript :: react event for modals 
Javascript :: node.js http server 
Javascript :: js destructuring 
Javascript :: response intersepters for axios create 
Javascript :: class component in react 
Javascript :: s3.getobject nodejs example 
Javascript :: Append to the text in the <p tag 
Javascript :: check cookies client side 
Javascript :: start button js 
Javascript :: indexof js 
Javascript :: web scrape example js 
Javascript :: aframe react 
Javascript :: jsdoc object destructuring 
Javascript :: what to use let vs var js 
Javascript :: update state in useState hook 
Javascript :: shell 
Javascript :: how to add multiple event listener in javascript 
Javascript :: check if token is expired 
Javascript :: sweetalert2 small icon 
Javascript :: axios get request 
Javascript :: angular2-tree-diagram 
Javascript :: react hook state not updating immediately 
Javascript :: reduce method 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =