2016-11-13 7 views
0

変更ステータスのクリックで作業するにはpjaxが必要ですが、正常に機能していますが、URLも変更しないようにしてください。Pjaxコンテナ(Yii2)内の特定のURLでenablePushState = falseを設定します。

<?php Pjax::begin(['id'=>'pjax-container-agency-index', 'timeout' => 10000, 'enablePushState' => true]); ?> 
<?= GridView::widget([..., 
      [ 
       'label' => 'Status', 
       'format' => 'raw', 
       'value' => function ($data) { 
        if ($data->deactive == 0) { 
         return Html::a(FA::i('circle'), ['agency/change-status', 'id' => $data->member_id, 'set' => 1], ['onclick' => "return confirm('Deactive this state/site?');", 'class' => 'status-inactive']); 
        } else { 
         return Html::a(FA::i('circle'), ['agency/change-status', 'id' => $data->member_id, 'set' => 0], ['onclick' => "return confirm('Active this state/site?');", 'class' => 'status-active']); 
        } 
       }, 
      ], 
]); 
<?php Pjax::end(); ?> 

actionChangeStatus()次のようにされています:以下のコードがある

public function actionChangeStatus($id, $set) { 
    if (!empty($id) && isset($set)) { 
     $localGovt = $this->findModel($id); 
     $localGovt->deactive = $set; 
     if ($localGovt->save()) { 
      Yii::$app->getSession()->setFlash('success-status', 'State Status Changed'); 
     } else { 
      Yii::$app->getSession()->setFlash('error-status', 'There is some error. Please consult with Admin.'); 
     } 
     $searchModel = new AgencySearch(); 
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams); 

     return $this->render('index', [ 
      'searchModel' => $searchModel, 
      'dataProvider' => $dataProvider 
     ]); 
    } 
} 

注:は、私は他のイベントのために'enablePushState' => trueを必要とするので、私は内部のfalseにそれを変更することはできませんPjax::begin

答えて

0

私はそれがだと信じている

'enableReplaceState' => true 
関連する問題