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

Can not select filter item after reresh data from ajax #173

Open
lchhieu opened this issue Jun 29, 2020 · 1 comment
Open

Can not select filter item after reresh data from ajax #173

lchhieu opened this issue Jun 29, 2020 · 1 comment

Comments

@lchhieu
Copy link

lchhieu commented Jun 29, 2020

  • Search and select search items works normally the first time
  • Load new data from ajax and append to select box . Refresh Duallistbox
  • Search and can not select search items
@caffeinatedMike
Copy link

I'm currently running into this scenario. Did you ever find a fix or workaround? I tried re-instantiating the instance, but that didn't help. Below is my implementation:

<script>
        $(function () {
            //Bootstrap Duallistbox
            $('.duallistbox').bootstrapDualListbox({
                nonSelectedListLabel: 'Available Master Columns',
                selectedListLabel: 'Selected Master Columns'
            })

            var container = $('.bootstrap-duallistbox-container');
            container.addClass('d-none');

            $('#fetch_columns').on('click', function(e) {
                var project = $('#project').val();
                var dataset = $('#dataset').val();
                var mast_prod = $('#master_product_table').val();
                if (project != '' && dataset != '' && mast_prod != ''){
                    $(this).attr('disabled', true);
                    $.post(
                        "{{ url_for('api.system_defaults') }}",
                        {project: project, dataset: dataset, mast_prod: mast_prod},
                        function(data){
                            var select = $('select#required_master_columns.duallistbox');
                            if(select.prop) {
                              var options = select.prop('options');
                            } else {
                              var options = select.attr('options');
                            }
                            $('option', select).remove();

                            $.each(data, function(index, node) {
                                options[index] = new Option(node.text, node.id);
                            });
                            select.bootstrapDualListbox('refresh', true);
                            // i've also tried re-instantiating it: 
                            // select.bootstrapDualListbox('destroy');
                            // $('.duallistbox').bootstrapDualListbox({
                            //          nonSelectedListLabel: 'Available Master Columns',
                            //          selectedListLabel: 'Selected Master Columns'
                            //  })
                            container.removeClass('d-none');
                        }
                    );
                }
            });
        });
    </script>

@istvan-ujjmeszaros any ideas?

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

No branches or pull requests

2 participants