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

Add: populate and sort function. #98

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

Conversation

KyleScharnhorst
Copy link
Contributor

provided a method that can help correctly order chosen elements in their desired order from a model that was returned from the server. Elements need to have the selected prop and the data-sortindex attr with the correct index. then call the populateAndSort method.

example:

            var options = $('#my_report_options').bootstrapDualListbox({
                sortByInputOrder: true
            });

            var sort_index = 0;
            $('#my_report_selections').children().each(function () {
                var target = this.label;
                $('#my_report_options').children().each(function () {
                    if (this.label == target) {
                        $(this).prop("selected", true);
                        $(this).attr("data-sortindex", sort_index++);
                    }
                });
            });

            options.bootstrapDualListbox("populateAndSort", sort_index);

Allowed for me to manually set sort index of values and have them be
populated in the dual list box correctly. The goal behind this change was
so users can choose a particular series of elements from the list and post
them to the server, if there was an error then the model would be returned
and the chosen elements would end up back in the desired order if the
developer manually added the 'data-sortindex' attribute to the chosen
elements in the correct order, then called the populate and sort method.
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