Javascript datepicker未在显示事件之前触发
下面是我在对话框中为日期选择器编写的代码,它工作得很好,但我想根据php服务器时间而不是本地时区设置默认日期和日历日期。 为此,我正试图做一个赛前表演,但这根本不是射击 任何人有什么建议吗Javascript datepicker未在显示事件之前触发,javascript,jquery,datepicker,Javascript,Jquery,Datepicker,下面是我在对话框中为日期选择器编写的代码,它工作得很好,但我想根据php服务器时间而不是本地时区设置默认日期和日历日期。 为此,我正试图做一个赛前表演,但这根本不是射击 任何人有什么建议吗 $('#chooseDt').click(function() { $("#Date_calendar").dialog({ open: function(event, ui) {
$('#chooseDt').click(function() {
$("#Date_calendar").dialog({
open: function(event, ui) {
$( "#dpicker" ).datepicker({
autoSize: true,
showOtherMonths: true,
numberOfMonths: 3,
showCurrentAtPos: 1,
onSelect: function(input, inst) {
var currentDate = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay);
var unixdate = currentDate.getTime() / 1000;
$(this).datepicker('destroy');
$(this).parent("div#Date_calendar").dialog( "close" );
window.location.href="xxxxxx.php?homeday="+(unixdate);
},
beforeShow: function() {
alert("A");
//var theDate = new Date();
//theDate.setDate('<?php echo date("d",strtotime($c_date)); ?>');
// calenderDate is my global php variable with date used as currentdate in my php page
//$(this).datepicker('option','defaultDate',calenderDate);
}
});
},
close: function(event,ui) {
$(this).datepicker('destroy');
},
resizable: false,
modal: true,
minWidth: 760
}).height("auto");
$( "#Date_calendar" ).dialog('widget').css({'top' : '25%', 'left' : '30%','margin-top' : '-10%', 'margin-left' : '-100px'});
return false;
});
$('#chooseDt')。单击(函数(){
$(“日期日历”)。对话框({
打开:功能(事件、用户界面){
$(“#dpicker”).日期选择器({
自动调整大小:正确,
showOtherMonths:是的,
月数:3,
showCurrentAtPos:1,
onSelect:功能(输入、安装){
var currentDate=新日期(inst.selectedYear、inst.selectedMonth、inst.selectedDay);
var unixdate=currentDate.getTime()/1000;
$(this.datepicker('destroy');
$(此).parent(“div#Date_calendar”).dialog(“close”);
window.location.href=“xxxxxx.php?homeday=“+(unixdate);
},
beforeShow:function(){
警报(“A”);
//var theDate=新日期();
//设定日期(“”);
//calenderDate是我的全局php变量,日期用作我的php页面中的currentdate
//$(此).datepicker('option','defaultDate',calenderDate);
}
});
},
关闭:功能(事件、用户界面){
$(this.datepicker('destroy');
},
可调整大小:false,
莫代尔:是的,
最小宽度:760
}).高度(“自动”);
$(“日期日历”).dialog('widget').css({'top':'25%,'left':'30%,'margin-top':'-10%,'margin-left':'-100px');
返回false;
});
fiddle为了更好地理解,任何人都可以帮忙吗?你能用更少的话解释这个问题吗?请参考我只想在展会活动之前使用的小提琴,它看起来像是beforeshow
不适用于内联日期采集器。你可以简单地调用$(“#dpicker”).datepicker(“option”,“defaultDate”,the date)代码>而不是在显示前使用
。