Detect form button in JS form submission handler
This commit is contained in:
parent
bafa8cc032
commit
a5e41f6c08
|
@ -229,6 +229,7 @@
|
|||
var regex = new RegExp('&', 'g');
|
||||
var url = $form.attr('action').replace(regex, '&'); // WHY??
|
||||
var method = $form.attr('method');
|
||||
var $button = $('input[type=submit]:focus', $form);
|
||||
var $target;
|
||||
var data;
|
||||
|
||||
|
@ -238,6 +239,10 @@
|
|||
method = method.toUpperCase();
|
||||
}
|
||||
|
||||
if ($button.length === 0) {
|
||||
$button = $('input[type=submit]', $form).first();
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
|
@ -250,9 +255,13 @@
|
|||
} else {
|
||||
data = $form.serializeArray();
|
||||
|
||||
// TODO: Check button
|
||||
if (typeof autosubmit === 'undefined' || ! autosubmit) {
|
||||
data.push({ name: 'btn_submit', value: 'yesss' });
|
||||
if ($button.length) {
|
||||
data.push({
|
||||
name: $button.attr('name'),
|
||||
value: $button.attr('value')
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
icinga.loader.loadUrl(url, $target, data, method);
|
||||
|
|
Loading…
Reference in New Issue