From 3daa177ea2c75b4a131ed10adc1afd6bc3e6735e Mon Sep 17 00:00:00 2001 From: Christophe BOULAIN Date: Tue, 4 Mar 2014 10:21:11 +0100 Subject: [PATCH] Add an option to ignore pjax request on some links. --- framework/assets/pjax/jquery.pjax.js | 4 ++++ framework/grid/ActionColumn.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/framework/assets/pjax/jquery.pjax.js b/framework/assets/pjax/jquery.pjax.js index 1934d808f6..10ec9fd0ca 100644 --- a/framework/assets/pjax/jquery.pjax.js +++ b/framework/assets/pjax/jquery.pjax.js @@ -61,6 +61,10 @@ var link = event.currentTarget + // Ignore links with data-pjax="0" + if ($(link).data('pjax')==0) + return + if (link.tagName.toUpperCase() !== 'A') throw "$.fn.pjax or $.pjax.click requires an anchor element" diff --git a/framework/grid/ActionColumn.php b/framework/grid/ActionColumn.php index ffcfe0a852..7d42becf6f 100644 --- a/framework/grid/ActionColumn.php +++ b/framework/grid/ActionColumn.php @@ -88,6 +88,7 @@ class ActionColumn extends Column $this->buttons['view'] = function ($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('yii', 'View'), + 'data-pjax' => '0', ]); }; } @@ -95,6 +96,7 @@ class ActionColumn extends Column $this->buttons['update'] = function ($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('yii', 'Update'), + 'data-pjax' => '0', ]); }; } @@ -104,6 +106,7 @@ class ActionColumn extends Column 'title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', 'Are you sure to delete this item?'), 'data-method' => 'post', + 'data-pjax' => '0', ]); }; }