Commit 7031020c by Qiang Xue

Fixes #6661: Hyperlinks that are enclosed within an exist form will use the same…

Fixes #6661: Hyperlinks that are enclosed within an exist form will use the same form for submission if they specify both of the `href` and `data-method` attributes
parent e9bbae9a
...@@ -9,6 +9,7 @@ Yii Framework 2 Change Log ...@@ -9,6 +9,7 @@ Yii Framework 2 Change Log
- Enh #6493: Added support for the `Access-Control-Expose-Headers` header by `yii\filters\Cors` (usualdesigner) - Enh #6493: Added support for the `Access-Control-Expose-Headers` header by `yii\filters\Cors` (usualdesigner)
- Enh #6697: Added `yii\helpers\Url::current()` method that allows adding or removing parameters from current URL (samdark, callmez) - Enh #6697: Added `yii\helpers\Url::current()` method that allows adding or removing parameters from current URL (samdark, callmez)
- Chg #5690: adjusted paths in message config generated by `yii message/config` to reflect directory structure better (mikehaertl, samdark) - Chg #5690: adjusted paths in message config generated by `yii message/config` to reflect directory structure better (mikehaertl, samdark)
- Chg #6661: Hyperlinks that are enclosed within an exist form will use the same form for submission if they specify both of the `href` and `data-method` attributes (qiangxue)
2.0.2 January 11, 2015 2.0.2 January 11, 2015
......
...@@ -158,7 +158,7 @@ yii = (function ($) { ...@@ -158,7 +158,7 @@ yii = (function ($) {
return; return;
} }
var newForm = !$form.length || action && action != '#'; var newForm = !$form.length;
if (newForm) { if (newForm) {
if (!action || !action.match(/(^\/|:\/\/)/)) { if (!action || !action.match(/(^\/|:\/\/)/)) {
action = window.location.href; action = window.location.href;
...@@ -197,9 +197,17 @@ yii = (function ($) { ...@@ -197,9 +197,17 @@ yii = (function ($) {
var oldMethod = $form.prop('method'); var oldMethod = $form.prop('method');
$form.prop('method', method); $form.prop('method', method);
var oldAction = null;
if (action && action != '#') {
oldAction = $form.prop('action');
$form.prop('action', action);
}
$form.trigger('submit'); $form.trigger('submit');
if (oldAction != null) {
$form.prop('action', oldAction);
}
$form.prop('method', oldMethod); $form.prop('method', oldMethod);
// remove the temporarily added hidden inputs // remove the temporarily added hidden inputs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment