From 25b117851567d07c4920b07c89a8f1198d9adede Mon Sep 17 00:00:00 2001 From: Sam Mousa Date: Thu, 3 Dec 2015 16:01:11 +0000 Subject: [PATCH 1/2] Implemented data-form support. --- framework/CHANGELOG.md | 1 + framework/assets/yii.js | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 6536c63459..5edc959f1a 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -56,6 +56,7 @@ Yii Framework 2 Change Log - Enh #10061: `yii\helpers\BaseInflector::transliterate()` is now public. Introduced different levels of transliteration strictness (silverfire) - Enh #10118: Allow easy extension of slug generation in `yii\behaviors\SluggableBehavior` (cebe, hesna) - Enh: Added last resort measure for `FileHelper::removeDirectory()` fail to unlink symlinks under Windows (samdark) +- Enh: #9893: Added support for data-form attribute so links can target specific forms (SamMousa) - Chg #9369: `Yii::$app->user->can()` now returns `false` instead of erroring in case `authManager` component is not configured (creocoder) - Chg #9411: `DetailView` now automatically sets container tag ID in case it's not specified (samdark) - Chg #9953: `TimestampBehavior::getValue()` changed to make value processing consistent with `AttributeBehavior::getValue()` (silverfire) diff --git a/framework/assets/yii.js b/framework/assets/yii.js index ccf1c96181..8fdf7841fe 100644 --- a/framework/assets/yii.js +++ b/framework/assets/yii.js @@ -144,8 +144,8 @@ yii = (function ($) { * @param $e the jQuery representation of the element */ handleAction: function ($e, event) { - var method = $e.data('method'), - $form = $e.closest('form'), + var $form = $e.attr('data-form') ? $('#' + $e.attr('data-form')) : $e.closest('form'), + method = !$e.data('method') && $form ? $form.attr('method') : $e.data('method'), action = $e.attr('href'), params = $e.data('params'), pjax = $e.data('pjax'), @@ -322,9 +322,10 @@ yii = (function ($) { var handler = function (event) { var $this = $(this), method = $this.data('method'), - message = $this.data('confirm'); + message = $this.data('confirm'), + form = $this.data('form'); - if (method === undefined && message === undefined) { + if (method === undefined && message === undefined && form === undefined) { return true; } From f390e8c0698fed47739ea1c7da9f9523fa4ea5a0 Mon Sep 17 00:00:00 2001 From: SilverFire - Dmitry Naumenko Date: Thu, 25 Feb 2016 15:48:03 +0200 Subject: [PATCH 2/2] Updated CHANGELOG --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index b9465bd688..ffe4905828 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -8,6 +8,7 @@ Yii Framework 2 Change Log - Bug #10850: Fixed unable to use 'definitions' and 'aliases' at `yii\widgets\MaskedInput` (rahimov, klimov-paul) - Bug #10946: Fixed parameters binding to the SQL query in `yii\db\mysqlSchema::findConstraints()` (silverfire) - Enh #5469: Add mimetype validation by mask in FileValidator (kirsenn, samdark, silverfire) +- Enh #9893: `yii.js` handleAction enhanced to support for data-form attribute, so links can trigger specific forms (SamMousa) - Enh #10487: `yii\helpers\BaseArrayHelper::index()` got a third parameter `$groupBy` to group the input array by the key in one or more dimensions (quantum13, silverfire, samdark) - Enh #10451: Check of existence of `$_SERVER` in `\yii\web\Request` before using it (quantum13) - Enh #10610: Added `BaseUrl::$urlManager` to be able to set URL manager used for creating URLs (samdark) @@ -135,7 +136,6 @@ Yii Framework 2 Change Log - Enh #10797: Cleaned up requirements checker CSS (muhammadcahya) - Enh: Added last resort measure for `FileHelper::removeDirectory()` fail to unlink symlinks under Windows (samdark) - Enh: `AttributeBehavior::getValue()` now respects the callable in array format (silverfire) -- Enh: #9893: Added support for data-form attribute so links can target specific forms (SamMousa) - Chg #6419: Added `yii\web\ErrorHandler::displayVars` make list of displayed vars customizable. `$_ENV` and `$_SERVER` are not displayed by default anymore (silverfire) - Chg #9369: `Yii::$app->user->can()` now returns `false` instead of erroring in case `authManager` component is not configured (creocoder) - Chg #9411: `DetailView` now automatically sets container tag ID in case it's not specified (samdark)