How to activate the datepicker on click but NOT on focus

2,609 views
Skip to first unread message

George Richardson

unread,
Dec 18, 2013, 5:43:11 PM12/18/13
to bootstrap-...@googlegroups.com
I dont want the datepicker to pop up when the field receives focus, eg. by tabbing or setting focus with javascript. I only want it to pop up when it is clicked (or whe just the calendar icon is clicked)

Is there a way to do this?


Andrew Rowls

unread,
Dec 20, 2013, 5:40:06 PM12/20/13
to George Richardson, bootstrap-...@googlegroups.com
Currently, no, there's no way to limit what triggers the picker to show.

This feature may be useful once it's implemented, but there's currently no timeline for it: https://github.com/eternicode/bootstrap-datepicker/issues/377

Alternatively, you could simply attach the datepicker to the add-on and work with the javascript events to populate the input. It won't be a perfect solution, but it may be good enough.
> --
> You received this message because you are subscribed to the Google Groups "bootstrap-datepicker" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bootstrap-datepi...@googlegroups.com.
> To post to this group, send email to bootstrap-...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/bootstrap-datepicker/01c7defe-dcb2-4397-b654-fef55df541e0%40googlegroups.com.

Michael Bernards

unread,
May 19, 2014, 5:13:36 AM5/19/14
to bootstrap-...@googlegroups.com, George Richardson
Because I really needed this feature, I implemented it in the latest stable version. I just added a new parameter called showOnFocus und set it in the default object to true.

In _buildEvents I found the following line in the component block:

focus: $.proxy(this.show, this),


I changed it to:


focus: $.proxy(function(e){

if (this.o.showOnFocus) /*TODO:konfiguration einbauen*/

this.show();

}, this),


Now I had only to make a markup as a component and set the showOnFocus to false and the calendar will only appear if I click on the button.
Reply all
Reply to author
Forward
0 new messages