2016-11-13 81 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其他事件,所以我不能將其更改爲falsePjax::begin

回答

0

我相信這是

'enableReplaceState' => true