mdbootstrap / bootstrap-templates

A collection of free Bootstrap 5 templates.
https://mdbootstrap.com/freebies/
3.07k stars 1.01k forks source link

tagsinput typeahead empty input have value [] #660

Closed gzai closed 5 years ago

gzai commented 5 years ago

Hello,

            var elt = $('.tags');
            elt.tagsinput({
                itemValue: 'id',
                itemText: 'title',
                trimValue: true,
                allowDuplicates: false,
                maxTags: 10,
                typeahead: {
                            name: 'tags',
                            displayKey: 'title',
                            source: function(query) {

                                return $.get( url , { search: query, return: 'data' }, function (values) {
                                            return values;
                                });

                            },
                            afterSelect: function() {
                                this.$element[0].value = '';
                        }
                }
            });

why tagsinput with typeahead adding [] in input value when input tag is empty? I type in console browser $('.tags').val(); , return value is "[]" . how to remove this value "[]" when input tag is empty ?

Thanks