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