Commit 4acab5c4 by Qiang Xue

fixed data-method.

parent cb4488ae
...@@ -116,9 +116,9 @@ yii = (function ($) { ...@@ -116,9 +116,9 @@ yii = (function ($) {
} }
var $form = $e.closest('form'); var $form = $e.closest('form');
var newForm = !$form.length || $e.prop('href') != '';
if (newForm) {
var action = $e.prop('href'); var action = $e.prop('href');
var newForm = !$form.length || action;
if (newForm) {
if (!action || !action.match(/(^\/|:\/\/)/)) { if (!action || !action.match(/(^\/|:\/\/)/)) {
action = window.location.href; action = window.location.href;
} }
...@@ -129,11 +129,14 @@ yii = (function ($) { ...@@ -129,11 +129,14 @@ yii = (function ($) {
} }
if (!method.match(/(get|post)/i)) { if (!method.match(/(get|post)/i)) {
$form.append('<input name="_method" value="' + method + '" type="hidden">'); $form.append('<input name="_method" value="' + method + '" type="hidden">');
method = 'POST';
} }
if (!method.match(/(get|head|options)/i)) {
var csrfParam = pub.getCsrfParam(); var csrfParam = pub.getCsrfParam();
if (csrfParam) { if (csrfParam) {
$form.append('<input name="' + csrfParam + '" value="' + pub.getCsrfToken() + '" type="hidden">'); $form.append('<input name="' + csrfParam + '" value="' + pub.getCsrfToken() + '" type="hidden">');
} }
}
$form.hide().appendTo('body'); $form.hide().appendTo('body');
} }
...@@ -143,8 +146,13 @@ yii = (function ($) { ...@@ -143,8 +146,13 @@ yii = (function ($) {
activeFormData.submitObject = $e; activeFormData.submitObject = $e;
} }
var oldMethod = $form.prop('method');
$form.prop('method', method);
$form.trigger('submit'); $form.trigger('submit');
$form.prop('method', oldMethod);
if (newForm) { if (newForm) {
$form.remove(); $form.remove();
} }
......
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