javascript - Bootstrap-Datepicker Ajax+Json change date -
i have bootstrap-datepicker , want change date, using ajax+json, it's not working, date changes format , when select calendar box not assume date in input field. datepicker input have this:
<div class="form-group"> <label class="control-label col-md-3">data de carregamento</label> <div class="col-md-3"> <div class="input-group input-medium date date-picker" data-date-format="yyyy-mm-dd"> <input type="text" class="form-control" name="h_data" id="h_data" value=""> <span class="input-group-btn"> <button class="btn default" type="button"><i class="fa fa-calendar"></i> </button> </span> </div> </div> </div>
datepicker initialization:
var handledatepickers = function () { if (jquery().datepicker) { $('.date-picker').datepicker({ format: 'yyyy-mm-dd', autoclose: true, language: 'pt' }); } }
ajax call:
$.ajax({ url: 'php/cd_ener_ref.php?id='+id, type: 'post', datatype: 'json', success: function (data) { if (data.sucesso) { $.each(data, function (index, record) { if ($.isnumeric(index)) { $('#h_data').val(record.h_data); $('#h_data').datepicker("update", record.h_data); $('#h_data').datepicker('refresh'); } }) } } });
with datepicker input set default format , calendar not assuming input date. appreciated.
Comments
Post a Comment