Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre sort List by value #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kinseyost
Copy link

//initialize with previously sorted options
//By passing the previously sorted value taken from select2, in the form
//of an array of the previously selected options' values, the select2
//options will be ordered with the selected options sorted as they were
//before.

//Example:
previouslySortedOptions = ["3", "1", "2"];

//Initialize with ARRAY of previously sorted options.
$(select2multiselect).select2Sortable(previouslySortedOptions);

//with other config options, specify "data:previouslySortedOptions" as previously selected info
    $(select2multiselect).select2Sortable({
    bindOrder: 'formSubmit' // or `sortableStop`,
    sortableOptions: {
        // please refer to jQuery UI sortable API (http://api.jqueryui.com/sortable/)
    },
    select2Options:{ //give select2 config options as well.
        // please refer to select2 documentation (https://select2.github.io/)
    },
    data:previouslySortedOptions
});

//perform sorting after initialization
$(select2multiselect).select2SortableOrder(previouslySortedOptions );

@kinseyost kinseyost changed the title update for select2 configuration and ability to add pre-sorted list f… Pre sort List by value Aug 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant