craftpip / bootstrap-fullscreen-select

[unmaintained] Fullscreen select for mobile devices.
http://craftpip.github.io/bootstrap-fullscreen-select
MIT License
88 stars 24 forks source link

Multiple selection count issue #19

Open hashk99 opened 7 years ago

hashk99 commented 7 years ago

After selecting multiple options , the select box shows the length of total characters instead of selected element count 1 - two options slected

wrong count length of charactors

After testing the code I found that this issue can fix by changing the " _updateBtnCount " function. (Line no 185) as below. b = this.$triggerElement.next().find('option:selected').text() || this.$e.val(); into b = this.$e.val();

hashk99 commented 7 years ago

Of course I had to add another variable to fix if the user select only one element from a multiple selection. so finally it was like below `_updateBtnCount: function () {

        /*
         * Update generated button count.
         */
        if (this.$triggerElement.is('button') && this.$triggerElement.hasClass('btn-mobileSelect-gen')) {
            var a = this.$triggerElement.find('.text'),
                b = this.$e.val();//this.$triggerElement.next().find('option:selected').text() || this.$e.val();
                var  btext = this.$triggerElement.next().find('option:selected').text();
            if (b === null) {
                a.html('Nothing selected');
                return false;
            }
            if (this.isMultiple) {console.log(btext);
                if (b.length === 1) {
                    a.html(btext);
                } else {
                    a.html(b.length + ' items selected');
                }
            } else {console.log(b);
                a.html(b);
            }
        }
    },`