crlcu / multiselect

jQuery multiselect plugin with two sides. The user can select one or more items and send them to the other side.
MIT License
308 stars 128 forks source link

Option to 1 search for 2 select #184

Closed thallysondiasdmc closed 4 years ago

thallysondiasdmc commented 4 years ago

Could use 1 search field to search in both selects?

crlcu commented 4 years ago

Hi @thallysondiasdmc,

Basically, you can have something like:

<script type="text/javascript">
jQuery(document).ready(function($) {
    $(document).on('keyup', '[name="q"]', function () {
        $('[name="hiddenq"]').val(this.value).trigger('keyup');
    });

    $('#search').multiselect({
        search: {
            left: '<input type="text" name="q" class="form-control" placeholder="Search..." />',
            right: '<input type="hidden" name="hiddenq" class="form-control" placeholder="Search..." />',
        },
        fireSearch: function(value) {
            return value.length > 3;
        }
    });
});
</script>