0
我有2個datepickers之一爲dateend和另一個爲datestart。 當我點擊一個對話框窗體時,我在html中有一個按鈕。 然後詢問數據並填充模態形式的元素。模式形式有日期結束和日期開始。但似乎日期開始是唯一填充的。請幫助。我真的不知道什麼是錯的,卡住超過4天JQuery UI日期選擇器setdate不工作的一個datepicker
<script type="text/javascript">
$(document).ready(function() {
$("#dialog-form").dialog({
autoOpen: false,
show: "drop", //explode
hide: "clip",
autoResize: true,
height: '500',
width: 'auto',
draggable: false,
modal: true,
resizable: false
});
$('input[type="button"]').click(function() {
var buttonHolder = $('input[type="button"]');
$("#dialog-form").dialog("open");
$("#timeStart").timepicker({});
$("#dateStart").datepicker({
defaultDate: "+1w",
dateFormat: "yy/mm/d",
changeMonth: true,
changeYear: true,
numberOfMonths: 3,
minDate: new Date(), // min date should be date of today or the date which he set as startdate
onClose: function() { //selectedDate should be value. i think. problem lies in the selected.
$("#dateEnd").datepicker("option", "minDate", $(this).val());
}
});
$("#dateEnd").datepicker({
defaultDate: "+1w",
dateFormat: "yy/mm/d",
changeMonth: true,
changeYear: true,
numberOfMonths: 3,
onClose: function() {
$("#dateStart").datepicker("option", "maxDate", $(this).val()); //$(this).val()
}
});
$.ajax({
type: "POST",
dataType: "json",
url: "<?php echo site_url('ajax/getEventOfModal'); ?>",
data: {
id: $(this).attr('id'),
username: "<?php echo $this->session->userdata('email'); ?>"
},
success: function (data) {
$("#event_id").attr('value', buttonHolder.attr('id'));
$("#event_name").attr('value', data['name']);
$("#event_loc").text(data['loc']);
$("#event_desc").text(data['desc']);
$("#timeStart").timepicker('setTime', data['timeStart']);
var queryDate = data['dateStart'],
dateParts = queryDate.match(/(\d+)/g)
realDate = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]); // months are 0-based!
$('#dateStart').datepicker('setDate', realDate);
var queryDate2 = data['dateEnd'],
dateParts2 = queryDate2.match(/(\d+)/g)
realDate2 = new Date(dateParts2[0], dateParts2[1] - 1, dateParts2[2]); // months are 0-based!
$('#dateEnd').datepicker('setDate', realDate2);
}
});
});
});
</script>
'data'的價值是什麼?使用笨並 – Barmar
IM'code' $結構=陣列( '名稱'=> $行向> EVENT_NAME, '用戶名'=> $行向>用戶名, 'LOC'=> $行向>位置, '遞減'=> $行向>描述, 'timeStart'=> $行向> TIME_START, 'dateStart'=> $行向> DATE_START, 'dateEnd'=> $行向> DATE_END ) ; echo json_encode($ struct); – user1525703
事情是,它適用於datestart。但爲什麼不爲dateend – user1525703