Commit 4acab5c4 by Qiang Xue

fixed data-method.

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