Boostrap datepicker close-on-click event

Asked

Viewed 1,435 times

1

Using jQueryUI datepicker by default the date click event and the datepicker close works.

How can I do it on bootstrap datepicker ?

JS:

$('#data').datepicker({
  format: 'dd/mm/yyyy',
  language: 'pt-BR',
});

HTML:

<input id="data" class="form-control text-center" type="text">

1 answer

1


To close the datepicker automatically when selecting the date you can use initialize the plugin with the option autoclose.

$('#data').datepicker({
  format: 'dd/mm/yyyy',
  language: 'pt-BR',
  autoclose: true
});
  • does not work this option, I googled and found in stackoverflow USA an answer equal to this. and also the https://bootstrap-datepicker.readthedocs.org/en/releaseplugin documentation/

  • This option is available as of version 1.3.1 that can be downloaded from official repository. In this demo you can see this option working.

  • http://jsfiddle.net/filadown/wa5kp0pw/ how strange, I did a test on jsfiddle and it is running, now on my system it is not, and I confirmed several times the order of the files, 1 jquery,2 bootstrap, 3 datepicker,4 functions,js calling datepicker

  • I don’t know if you’ve tried or if this is the problem, but clearing the browser cache might help. Maybe you’re still loading the old version.

  • I tried to clear the cache before too, but it didn’t work.

  • Something on the console?

  • no message on the console... https://drive.google.com/file/d/0ByiDi-nlXfgVNXFUmZGeTZjQlE/view?usp=sharing

  • @Gabrielrodrigues You have not updated the js of datepicker. What is in your project is a 2012 version (js/plugins/datepicker.js).

  • That’s right, I always rename the file name to be simpler and semantic and at the time of replacing ended up not doing it

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.