2016-03-23 22 views
2

combodate jQuery kitaplığını kullanıyorum. AJAX'tan veri aldığımda alandaki değeri nasıl ayarlayabilirim? Dokümantasyonda bunun bir örneği yoktur. $(selector).val('var from ajax')'u denedim ama çalışmıyor.setValue üzerinde combodate.js tabanlı ajax yanıtı

<div class="form-group"> 
    <label class="control-label col-md-3">Selesai</label> 
    <div class="col-md-9"> 
     <div class="form-inline"> 
      <div class="form-group"> 
       <input name="tanggal_selesai" class="form-control combodate " type="text"> 
       <span class="help-block"></span> 
      </div> 
     </div> 
    </div> 
</div> 
$('.combodate').combodate({ 
    format: 'YYYY-MM-DD HH:mm',  
    template: 'DD/MM/YYYY HH : mm',  
    value: null, 
    minYear: 2015,  
    maxYear: new Date().getFullYear(), 
    yearDescending: true, 
    minuteStep: 1, 
    secondStep: 1, 
    firstItem: 'empty', 
    errorClass: null, 
    customClass: 'form-control', 
    roundTime: true, 
    smartDays: false 
}); 

$.ajax({ 
    url: "<?php echo site_url('members/it/request/ajax_edit/') ?>/" + id, 
    type: "GET", 
    dataType: "JSON", 
    success: function (response) { 
     $('[name="id"]').val(response.ID_REQUEST); 
     $('[name="nama"]').val(response.ID_KARYAWAN); 
     $('[name="tanggal_persetujuan"]').val(response.TANGGAL_PERSETUJUAN); 
     $('[name="tanggal_terima"]').val(response.TANGGAL_TERIMA); 
     $('[name="perkiraan_selesai"]').val(response.PERKIRAAN_SELESAI); 
     $('[name="tanggal_selesai"]').val(response.TANGGAL_SELESAI); 
     $('[name="pelaksana"]').val(response.PELAKSANA); 
     $('[name="keluhan"]').val(response.KELUHAN); 
     $('[name="catatan"]').val(response.CATATAN); 
     $('#modal_form').modal('show'); // show bootstrap modal when complete loaded 
     $('.modal-title').text('Edit Customer Data'); // Set title to Bootstrap modal title 
    }, 
    error: function (jqXHR, textStatus, errorThrown) { 
     alert('Error get data from ajax'); 
    } 
}); 

cevap

1

Eğer setValue() yöntemi kullanabilirsiniz belgelerine göre::

Setleri yeni değer İşte benim kodudur. Değer javascript Date() nesnesi veya options.format öğesinde dize olabilir.

$('[name="tanggal_selesai"]').combodate('setValue', response.TANGGAL_SELESAI). 
İlgili konular