E
E
EVOSandru62015-10-20 09:24:54
JavaScript
EVOSandru6, 2015-10-20 09:24:54

How to run Yii::app()->runController in isAjaxRequest block in Yii?

Good afternoon,

For some reason, this method works in the main body of the action, but nothing is generated with isAjaxRequest (

public function actionCreate()
  {
    if (Yii::app()->request->isAjaxRequest 
    {
                        // Тут не работает  = (((
      Yii::app()->runController('sadmin/hotels/update/id/1416');
      Yii::app()->end();
    }
    else
    {
      $model = new Hotels();

                        // тут работает
      Yii::app()->runController('sadmin/hotels/update/id/1416');

      $this->render('create', ['model'=>$model,]);
    }
  }


ajaxSubmitButton returns empty on success (

echo CHtml::ajaxSubmitButton
            (
                $model->isNewRecord ? 'Добавить номера' : 'Обновить',

                    Yii::app()->createUrl('sadmin/hotels/create'),
                    [
                        'success'=>'js:function(data)
                        {
                            displayMessage(data);
                            $("#hotels-form").remove();
                            $("#crud-hotel").append(data);
                        }',
                        'error'=>'js:function()
                        {
                            alert("Плохо");
                        }',
                    ],
                    [
                        'id'=>'add-hotel',
                        'class'=>'btn btn-primary btn-lg center-block',
                    ]
                );


The button itself works exactly, if you throw some in isAjaxRequestdie($value) , they return

Yii::app()->runController('sadmin/hotels/update/id/1416')
in isAjaxRequest it is definitely processed, because if I deliberately make a mistake inside the line 'sadmin/hotels/update/id/1416' then I get into the error block at ajaxSubmitButton

It is the display of the view that does not work(

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question