I have a bootstrap datepicker. I want the show event to be fired when the input box is first clicked. However I don't want the event to be fired if the user is traversing through the months with the prev and next arrows.
Is this possible?
$('#sandbox-container input').datepicker({
autoclose: true
});
$('#sandbox-container input').on('show', function(e){
console.log('show event');
});
If you run the fiddle you will see the message get logged when you first click the input field (I want that behavior). however you will also see that message displayed if you use the prev and next arrows.
JS Fiddler is here - http://jsfiddle.net/LcqM7/611/
It's a bit grim but you can leverage the
hide
event to unbind theshow
then reattach it using jqueriesone
.http://jsfiddle.net/5dhkumko/
You will need to check if the
show
already "run" in the current "state".And a working example:
http://jsfiddle.net/k6b3yepb/