js: allow non-<form> elements as popup main widget (#18887)
This commit is contained in:
parent
f0a8f03f17
commit
5e06b6cb90
|
@ -150,7 +150,7 @@ var gadjo_js = gadjo_js || {};
|
|||
/* get title out of html */
|
||||
var title = $html.find(title_selector).text();
|
||||
|
||||
$form.dialog({
|
||||
$content.dialog({
|
||||
modal: modal,
|
||||
'title': title,
|
||||
width: 'auto',
|
||||
|
@ -166,10 +166,10 @@ var gadjo_js = gadjo_js || {};
|
|||
|
||||
/* hide buttons from content and convert buttons (<button> and <a>)
|
||||
* into proper dialog buttons */
|
||||
$form.find('.buttons').hide();
|
||||
$content.find('.buttons').hide();
|
||||
|
||||
var buttons = Array();
|
||||
$form.find('.buttons button, .buttons a').each(function(idx, elem) {
|
||||
$content.find('.buttons button, .buttons a').each(function(idx, elem) {
|
||||
var $elem = $(elem);
|
||||
var button = Object();
|
||||
|
||||
|
@ -180,7 +180,7 @@ var gadjo_js = gadjo_js || {};
|
|||
if ($elem.hasClass('cancel')) {
|
||||
/* special behaviour for the cancel button: do not send
|
||||
* anything to server, just close the dialog */
|
||||
button.click = function() { $form.dialog('destroy'); return false; };
|
||||
button.click = function() { $content.dialog('destroy'); return false; };
|
||||
} else {
|
||||
button.click = function() {
|
||||
if (inplace_submit) {
|
||||
|
@ -198,11 +198,11 @@ var gadjo_js = gadjo_js || {};
|
|||
data: $form.serialize(),
|
||||
}).success(function(data) {
|
||||
$anchor.trigger('gadjo:dialog-done', data);
|
||||
$form.dialog('destroy');
|
||||
$content.dialog('destroy');
|
||||
}).fail(function() { $anchor.trigger('gadjo:dialog-submit-error');
|
||||
});
|
||||
} else {
|
||||
$form.find('button').click();
|
||||
$content.find('button').click();
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
@ -220,7 +220,7 @@ var gadjo_js = gadjo_js || {};
|
|||
});
|
||||
|
||||
buttons.reverse();
|
||||
$form.dialog('option', 'buttons', buttons);
|
||||
$content.dialog('option', 'buttons', buttons);
|
||||
|
||||
/* focus initial input field */
|
||||
if ($form.find('input:visible').length) {
|
||||
|
@ -236,7 +236,7 @@ var gadjo_js = gadjo_js || {};
|
|||
}
|
||||
});
|
||||
}
|
||||
$anchor.trigger('gadjo:dialog-loaded', $form);
|
||||
$anchor.trigger('gadjo:dialog-loaded', $content);
|
||||
});
|
||||
return false;
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue