bootstrap-datepicker icon indicating copy to clipboard operation
bootstrap-datepicker copied to clipboard

[bug]click another elements hidden datepicker will hidden also

Open joebnb opened this issue 11 years ago • 8 comments

<div class="alert alert-success">
    <div class="close">X</div>
    somenotify
</div>
<div id="datepicker"></div>
<script type="text/javascript">

    $('#datepicker').datepicker({
                format: "yyyy/mm/dd",
                weekStart: 0,
                //language: "zh-CN",
                todayHighlight: true
            });
</script>

if i click X to hidden alert,.date time will hidden...i dont konw why will cause this,i use it in Embedded / inline model i found here was a bug,i think it should determined did this works inline:

                [$(document), {
                    mousedown: $.proxy(function(e){
                        // Clicked outside the datepicker, hide it
                        if (!(
                            this.element.is(e.target) ||
                            this.element.find(e.target).length ||
                            this.picker.is(e.target) ||
                            this.picker.find(e.target).length
                        )){
                            //$(this.picker).hide();
                        }
                    }, this)

joebnb avatar Apr 11 '15 04:04 joebnb

                    mousedown: $.proxy(function(e){
                        // Clicked outside the datepicker, hide it
                        if (!(
                            this.element.is(e.target) ||
                            this.element.find(e.target).length ||
                            this.picker.is(e.target) ||
                            this.picker.find(e.target).length ||
                            this.element.attr('data-module') != 'inline'
                        )){
                            $(this.picker).hide();
                        }

i redit like this, and if i want make it inline,will add attributes data-module=“inline”

joebnb avatar Apr 20 '15 10:04 joebnb

wish fix it in next update

joebnb avatar Apr 20 '15 10:04 joebnb

+1 Joebnb I've hit this bug also I'll clarify this here to make sure it's the same issue joebnb mentions above.

When the datepicker is being used in inline/embedded mode, it's hidden whenever another mousedown is called on another element on the page.

at first look Joe's fix seems to work.

NeilWkz avatar May 12 '15 15:05 NeilWkz

May I know why the example didn't hit the bug? the inline mode of datepicker is not hidden up.

http://eternicode.github.io/bootstrap-datepicker/?markup=embedded&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&todayBtn=false&clearBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox

alvin0618 avatar May 20 '15 04:05 alvin0618

Fixed, code should be like this

            mousedown: $.proxy(function(e){
                    // Clicked outside the datepicker, hide it
                    if (!(
                        this.element.is(e.target) ||
                        this.element.find(e.target).length ||
                        this.picker.is(e.target) ||
                        this.picker.find(e.target).length ||
                        this.isInline == true
                    )){
                        $(this.picker).hide();
                    }
             }, this)

alvin0618 avatar May 21 '15 01:05 alvin0618

@alvin0618 this bug appears in 1.4.1-dev, the example page has 1.4.1 stable.

I'm not sure what introduced this funny bug, should we create a pull request for it?

razvanphp avatar May 26 '15 18:05 razvanphp

Yes please, if you have a fix create a PR for it. So the we can review it and check if the original problem (what was fixed in the currently broken code) is still fixed

acrobat avatar May 27 '15 10:05 acrobat

@razvanphp i downloaded the 1.5.0dev version, the problem is still there.

alvin0618 avatar Jun 02 '15 07:06 alvin0618