CJuiDatePicker选择周

时间:2014-11-03 11:14:23

标签: php jquery yii datepicker

我想在Yii中使用datepicker选择一周。我有以下代码。

<?php
                $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'name'=>'accountingweekselect',
                    'value' => date('d-M-y'),
                    'flat'=>true,               
                    'htmlOptions' => array(
                        'size' => '10',         // textField size
                    ),
                    'options'=>array(
                        'dateFormat'=>'yy-m-dd',
                        'firstDay'=> 5,
                        'onSelect' => 'js: function(dateText, inst){
                                //$("#accountingweekselect_container").datepicker("setDate",dateText );
                        }',
                        'maxDate' => 'today',
                        'selectWeek'=>true,
                    )

                ));
                ?>

我会让它像以下链接一样工作。 http://2008.kelvinluck.com/assets/jquery/datePicker/v2/demo/datePickerSelectWeek.html

也许我可以使用onselect来选择日期并使用css突出显示该行。以下代码仅记录容器,而不是您选择的日期。

'onSelect' =>
                            'js:function() {
                                // to automatically assign check out date input value
                                console.log(this);
                            }',

更新代码

$this->widget('zii.widgets.jui.CJuiDatePicker', array(
                    'name'=>'accountingweekselect',
                    'value' => date('d-M-y'),
                    'flat'=>true,               
                    'htmlOptions' => array(
                        'size' => '10',         // textField size
                    ),
                    'options'=>array(
                        //'dateFormat'=>'yy-m-dd',
                        'dateFormat'=>'yy-mm-dd',
                        //'firstDay'=> 5,
                        'showOtherMonths'=>true,// Show Other month in jquery
                        'selectOtherMonths'=>true,// Select Other month in jquery
                        'onSelect' => 'js: function(dateText, inst){
                            console.log($("#accountingweekselect_container div table tbody tr td").children("a.ui-state-active").html());
                            console.log($("#accountingweekselect_container div table tbody tr td.ui-datepicker-current-day").children("a").html());
                        }',
                        //'maxDate' => 'today',
                        /*'onSelect' =>
                            'js:function() {
                                // to automatically assign check out date input value
                                console.log(this);
                            }',*/
                        'selectWeek'=>true,
                    )

                ));

我已经评论了所有额外的选项,但仍然可以使用鼻涕。以下是源代码

jQuery('#accountingweekselect_container').datepicker({'dateFormat':'yy-mm-dd','selectWeek':true,'defaultDate':'03-Nov-14','altField':'#accountingweekselect'});

0 个答案:

没有答案