Search code examples
jqueryhtmlcsstwitter-bootstrap-3datepicker

Date-picker of Bootstrap 3 is cleaning another components, what could be?


For my date inputs, I'm using datepicker from bootstrap in javascript. But, when I'm done from select a date or just lost the focus of the selector, another components from the form is reseting its data.

Javascript:

Tc.MaskDate = (function(){
    
    function MaskDate() {
        this.inputDate = $('.js-date');
    }
    
    MaskDate.prototype.enable = function() {
        this.inputDate.mask('00/00/0000');
        this.inputDate.datepicker({
            orientation: 'bottom',
            language: 'pt-BR',
            autoclose: true
        });
    }
    
    return MaskDate;
    
})();

HTML:

class="js-date"

What happens:

enter image description here


Solution

  • Found the solution:

    $('.js-date').datepicker().on('changeDate', function(ev) {
        }).on('hide', function(event) {
        evnt.preventDefault();
        event.stopPropagation();
    });