craftpip / bootstrap-fullscreen-select

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

Dependent selects onClose fire multiple times #11

Open dfloresgonz opened 7 years ago

dfloresgonz commented 7 years ago

Hi I have came accross a bug, I have 4 selects one depends on the selected value of the previous one. I have my own functions called on the onClose function. 2 things.

1) The onClose function was getting called multiple times I notice it needed a unbind click in the _unbindEvents function. Add this line: this.$c.find('.mobileSelect-savebtn').unbind('click');

2) The onClose should be only called when the save-button is pressed for this I added a default parameter on the hide function.

`hide: function (save = null) {

        /*
         * hide animation with onClose callback
         */
        this.$c.children('div').addClass('anim-' + this.animation);
        var that = this;
        this._updateBtnCount();
        setTimeout(function () {
            that.$c.hide();
            $('body').removeClass('mobileSelect-noscroll');
            /* MY CHANGE BEGIN*/
            if(save) {
                that.onClose.apply(that.$e);
            }
            /* MY CHANGE END */
        }, this.animationSpeed);
    },`

Then on line 232 change this that.hide(); to this that.hide(true);

Double-L commented 7 years ago

I am sorry! Friends, now only to reply to your question! I am still in the learning stage, so I can‘t help you solve the problem. I am so sorry!