uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.66k stars 6.07k forks source link

Buggy when used with bootstrap button dropdown #528

Open whyAto8 opened 11 years ago

whyAto8 commented 11 years ago

This bug appears in this js version i.e. eternicode, but does not look like in the old one which is http://www.eyecon.ro/bootstrap-datepicker/.

When used in a bootstrap drop down, it doesnt work well. The issue could be looked at http://stackoverflow.com/questions/17480710/bootstrap-datepicker-in-bootstrap-button-drop-down?noredirect=1#comment25405762_17480710

and replicated at http://jsfiddle.net/eqwWJ/

m-idler commented 11 years ago

I've got the same problem with the datepicker attached to a dropdown menu. I think that the solution is to stop the event propagation in the click callback, either with e.stopPropagation() or by returning false.

whyAto8 commented 11 years ago

Thanks a lot for that. I did tried this and its working. :-)

Regards Yogesh Arora

On Wed, Sep 4, 2013 at 5:38 PM, poeppe notifications@github.com wrote:

I've got the same problem with the datepicker attached to a dropdown menu. I think that the solution is to stop the event propagation in the click callback, either with e.stopPropagation() or by returning false.

— Reply to this email directly or view it on GitHubhttps://github.com/eternicode/bootstrap-datepicker/issues/528#issuecomment-23784241 .

sampalmer commented 10 years ago

Here's some code to demonstrate one way of working around this:

$('#your-datepicker')
    .datepicker()
    .on('show', function(e) {
        $('.datepicker').click(function () { return false; });
    });

I'm not sure if this works without any unwanted side-effects, but it does at least work for me.