Skip to content

Commit

Permalink
JS/submitForm: Choosing the right submit button in FF
Browse files Browse the repository at this point in the history
refs #7751
  • Loading branch information
mxhash committed Nov 20, 2014
1 parent 4e87d21 commit b0382da
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions public/js/icinga/events.js
Expand Up @@ -186,6 +186,7 @@
*
*/
submitForm: function (event, autosubmit) {
//return false;
var self = event.data.self;
var icinga = self.icinga;
// .closest is not required unless subelements to trigger this
Expand All @@ -198,9 +199,23 @@
var data;

if ($button.length === 0) {
var $el = $(event.currentTarget);
if ($el.is('input[type=submit]') || $el.is('button[type=submit]')) {
var $el;

if (typeof event.originalEvent !== 'undefined'
&& typeof event.originalEvent.explicitOriginalTarget === 'object') { // Firefox
$el = $(event.originalEvent.explicitOriginalTarget);
icinga.logger.info('events/submitForm: Button is event.originalEvent.explicitOriginalTarget');
} else {
$el = $(event.currentTarget);
icinga.logger.info('events/submitForm: Button is event.currentTarget');
}

if ($el && ($el.is('input[type=submit]') || $el.is('button[type=submit]'))) {
$button = $el;
} else {
icinga.logger.error(
'events/submitForm: Can not determine submit button, using the first one in form'
);
}
}

Expand Down

0 comments on commit b0382da

Please sign in to comment.