CJuiDatePicker小部件的工作不会让人感到困惑。当我用直接URL访问页面时,它工作正常,日历按要求显示,但问题是,当我用ajax调用将页面加载到动态部分时,只有文本字段出现,但点击后日历不显示。
$this->renderPartial('index', array('policyModel' => $policyModel, 'roomModel' => $roomModel, 'formModel' => $formModel,'response' => $response),false,true);
小工具代码
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name' => 'start_date',
'options' => array(
'dateFormat' => 'yy-mm-dd',
'showAnim' => 'fadeIn',
'changeMonth' => true,
'changeYear' => true,
'yearRange' => '2000:2099',
'minDate' => '+1d',
'maxDate' => '10Y',
),
'htmlOptions' => array(
'readonly' => 'readonly',
'size' => 7,
),
));
有谁能帮我吗?经过这么多小时的搜索,我发布了这个问题。
您必须为日期选择器设置一个唯一的ID。我使用php函数uniqid()
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
'id' => 'start_date'.uniqid(),
'name' => 'start_date',
'options' => array(
'dateFormat' => 'yy-mm-dd',
'showAnim' => 'fadeIn',
'changeMonth' => true,
'changeYear' => true,
'yearRange' => '2000:2099',
'minDate' => '+1d',
'maxDate' => '10Y',
),
'htmlOptions' => array(
'readonly' => 'readonly',
'size' => 7,
),
));
祝你好运!
您需要在ajax更新后重新初始化日期选择器。Ajax完成后,您需要添加以下行:
$('#start_date').datepicker(); //with your options