Commit 8d082c11 by Qiang Xue

Fixes #5050.

parent 583c660c
...@@ -118,18 +118,23 @@ yii = (function ($) { ...@@ -118,18 +118,23 @@ yii = (function ($) {
* For other elements, either the containing form action or the current page URL will be used * For other elements, either the containing form action or the current page URL will be used
* as the form action URL. * as the form action URL.
* *
* If the `data-method` attribute is not defined, nothing will be done. * If the `data-method` attribute is not defined, the `href` attribute (if any) of the element
* will be assigned to `window.location`.
* *
* @param $e the jQuery representation of the element * @param $e the jQuery representation of the element
*/ */
handleAction: function ($e) { handleAction: function ($e) {
var method = $e.data('method'); var method = $e.data('method'),
$form = $e.closest('form'),
action = $e.attr('href');
if (method === undefined) { if (method === undefined) {
if (action && action != '#') {
window.location = action;
}
return; return;
} }
var $form = $e.closest('form');
var action = $e.attr('href');
var newForm = !$form.length || action && action != '#'; var newForm = !$form.length || action && action != '#';
if (newForm) { if (newForm) {
if (!action || !action.match(/(^\/|:\/\/)/)) { if (!action || !action.match(/(^\/|:\/\/)/)) {
...@@ -227,12 +232,14 @@ yii = (function ($) { ...@@ -227,12 +232,14 @@ yii = (function ($) {
function initDataMethods() { function initDataMethods() {
var handler = function (event) { var handler = function (event) {
var $this = $(this); var $this = $(this),
// data-confirm requires data-method method = $this.data('method'),
if ($this.data('method') === undefined) { message = $this.data('confirm');
if (method === undefined && message === undefined) {
return true; return true;
} }
var message = $this.data('confirm');
if (message !== undefined) { if (message !== undefined) {
pub.confirm(message, function () { pub.confirm(message, function () {
pub.handleAction($this); pub.handleAction($this);
......
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