diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 8e92d2d3f4..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) diff --git a/framework/assets/yii.js b/framework/assets/yii.js index d946d40128..cf9168bada 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'), @@ -345,9 +345,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; }