D
D
des1roer2015-05-27 14:33:49
JavaScript
des1roer, 2015-05-27 14:33:49

Yii ajax CJuiDatePicker and dropDownList?

yii 1.1.16
tell me how to update the content block in the least labor-intensive way when selecting a date in the datepicker and/or selecting a shift in the drop-down list?
UPD
c dropDownList sort of figured out the
twist

echo CHtml::dropDownList('listname',$mysmen, 
              array('1' => '1 смена', '2' => '2 смена','3' => '3 смена'),
        array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('quality/smen'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#content', //selector to update
'data' => array
            (
            'smen' => 'js:this.value',
    )
//leave out the data key to pass all form values through
)));

controller
public function actionSmen()
{
    $smen = Yii::app()->request->getParam('smen');
    $model=new Quality('search');
    $model->unsetAttributes();  // clear any default values
    if(isset($_GET['Quality']))
      $model->attributes=$_GET['Quality'];                    
    $this->renderPartial('admin',array(
      'model'=>$model,
          ));
}

checking the post
(isset($_POST['smen'])) ? $mysmen =$_POST['smen']: $mysmen = today_smen($todaysmen);

-----------
worked with the datepicker. just how to send a post? did through get what is not true
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    'name' => 'from_date',
    'value' => $date,
    'language' => 'ru',
    'options' => array(
        'showAnim' => 'fold',
        'dateFormat' => 'yy-mm-dd',       
        'onSelect' => 'js: function(dateText, inst) {window.location.search = "date=" + this.value; return false;}',
    ),
));

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Novikov, 2018-07-14
@dvnovikov

Print the value of input.prop('files') to the console, is there definitely something there?
Are the files already selected?
Or is it done on page load?

D
des1roer, 2015-05-28
@des1roer

dropDownList
c dropDownList sort of figured it out
twist

echo CHtml::dropDownList('listname',$mysmen, 
              array('1' => '1 смена', '2' => '2 смена','3' => '3 смена'),
        array(
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('quality/smen'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#content', //selector to update
'data' => array
            (
            'smen' => 'js:this.value',
    )
//leave out the data key to pass all form values through
)));

controller
public function actionSmen()
{
    $smen = Yii::app()->request->getParam('smen');
    $model=new Quality('search');
    $model->unsetAttributes();  // clear any default values
    if(isset($_GET['Quality']))
      $model->attributes=$_GET['Quality'];                    
    $this->renderPartial('admin',array(
      'model'=>$model,
          ));
}

checking the post
CJuiDatePicker
$this->widget('zii.widgets.jui.CJuiDatePicker', array(
    'name' => 'from_date',
    'value' => $date,
    'language' => 'ru',
    'options' => array(
        'showAnim' => 'fold',
        'dateFormat' => 'yy-mm-dd',
        //'onSelect' => 'js: function(dateText, inst) {window.location.search = "date=" + this.value; return false;}',
        'onSelect' => 'js: function(dateText, inst) {' .
        CHtml::ajax(array('type' => 'POST', 'datatype' => 'html', 'url' => array('Reports_ajax'),
            'data' => array('date' => 'js: dateText'),
            'success' => 'function(html){ $("#content").html(html);
                                                    return false; }'
                )
        ) .
        '}',
    ),
));

then controller
public function actionSmen()
{
    $smen = Yii::app()->request->getParam('smen');
    $smen = Yii::app()->request->getParam('date');
    $model=new Quality('search');
        $model->unsetAttributes();  // clear any default values
        if(isset($_GET['Quality']))
            $model->attributes=$_GET['Quality'];                    
        $this->renderPartial('admin',array(
            'model'=>$model,
                    ));
}

and check
(isset($_POST['date']) && $_POST['date']) ? $date = $_POST['date'] : $date = date('Y-m-d');

P
Puma Thailand, 2015-05-28
@opium

there is an onSelect event for CJuiDatePicker

'onSelect'=> 'js: function(dateText, inst) {
//тут ajax запрос и обновление контента , либо другая работа
}',

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question