I have the following bootstrap Daterange picker:
<div class="form-group">
<label class="control-label col-md-3">Inicio: </label>
<div class="col-md-7">
<div class="input-group input-large date-picker input-daterange" data-date="2014-03-01" data-date-format="yyyy-mm-dd" id="div_datas_funcao_atual">
<input type="text" class="form-control" name="funcao_atual_inicio" id="funcao_atual_inicio" value="<?php echo $Hoje ?>">
<span class="input-group-addon"> fim </span>
<input type="text" class="form-control" name="funcao_atual_fim" id="funcao_atual_fim" value="<?php echo $Hoje ?>">
</div>
</div>
</div>
And I have this code to update the Daterange picker:
function mostra_datas_empreitada(){
ID = $('#empreitada_atual').val();
$.ajax({
url: 'php/sst_pessoas.php?tipo_acao=empreitada_datas&id='+ID,
type: 'get',
data: { tag: 'getData'},
dataType: 'json',
success: function (dados) {
if (dados.sucesso) {
dt_inicial = dados.dt_inicio;
dt_final = dados.dt_fim;
$('#div_datas_funcao_atual').data('daterangepicker').setStartDate(dt_inicial);
$('#div_datas_funcao_atual').data('daterangepicker').setEndDate(dt_final);
}
}
});
}
The ajax call returns the following data:
{"sucesso":true,"dt_inicio":"2015-08-31","dt_fim":"2015-09-04"}
After ajax call, the DaterangePicker values don't change, and I receive the message "Cannot read property 'setStartDate' of undefined". I don't know what's wrong. Any help is appreciated. thanks.
I do not see the initialization of the component. Try this.