Datepicker does not work

1

I am building a system in which I have to register a stock plan, so far so good ...

At the time of registration there are three inputs, What, Who and When as shown below:

  

TheproblemiswhenIclickonthenew"When?" field, because the datepicker does not appear again ...   

Followthecode:

Script:

<script>$.(function(){$(".datepicker").datepicker({});

        $(".inserirItens").on('click', function() {
            var inputs = "aqui eu defino o html dos meus inputs que vão ser adicionados posteriormente";
            $(this).closest('.form-group').append(inputs);
        });
    });
</script>

HTML

<div class="form-group">
    <input type="text" name="oque" class="">
    <input type="text" name="quem" class="">
    <input type="text" name="quando" class="datepicker">
    <button class="inserirItens"><i class='icon icon-plus' ></i></button>
</div>
    
asked by anonymous 09.03.2015 / 19:35

2 answers

0

I was able to solve it as follows ...

$(".inserirItens").on('click', function() {
    var inputs = "aqui eu defino o html dos meus inputs que vão ser adicionados posteriormente";
    $(this).closest('.form-group').append(inputs);
    $(".inputDatepicker").datepicker("destroy");
    $(".inputDatepicker").datepicker("refresh");
});
  

I have not yet figured out why I have to break the datepicker at all times and then refresh myself ... but solved my case

Source: jqueryUi / Datepicker

    
12.03.2015 / 14:11
1
$('body').on('focus','.datepicker', function(){
    $(this).datepicker();
});
    
10.03.2015 / 17:10