Skip to content
Snippets Groups Projects
Commit 65f09b68 authored by Ere Maijala's avatar Ere Maijala
Browse files

Improved the clicked submit button detection to work on all platforms and...

Improved the clicked submit button detection to work on all platforms and cases where the form has multiple submit buttons.
parent 5a9f12e7
No related merge requests found
...@@ -45,6 +45,15 @@ VuFind.lightbox = (function() { ...@@ -45,6 +45,15 @@ VuFind.lightbox = (function() {
_modal.modal('show'); _modal.modal('show');
// Attach capturing events // Attach capturing events
_modalBody.find('a').on('click', _constrainLink); _modalBody.find('a').on('click', _constrainLink);
// Handle submit buttons attached to a form as well as those in a form. Store
// information about which button was clicked here as checking focused button
// doesn't work on all browsers and platforms.
_modalBody.find('[type=submit]').click(function() {
var form = $(this).prop('form') || $(this).closest('form')[0];
$(form.elements).filter('[type=submit]').removeAttr('clicked');
$(this).attr('clicked', true);
});
var forms = _modalBody.find('form'); var forms = _modalBody.find('form');
for(var i=0;i<forms.length;i++) { for(var i=0;i<forms.length;i++) {
$(forms[i]).on('submit', _formSubmit); $(forms[i]).on('submit', _formSubmit);
...@@ -141,7 +150,7 @@ VuFind.lightbox = (function() { ...@@ -141,7 +150,7 @@ VuFind.lightbox = (function() {
var data = $(form).serializeArray(); var data = $(form).serializeArray();
data.push({'name':'layout', 'value':'lightbox'}); // Return in lightbox, please data.push({'name':'layout', 'value':'lightbox'}); // Return in lightbox, please
// Add submit button information // Add submit button information
var submit = $(form).find('[type=submit]'); var submit = $(form).find('[type=submit][clicked]');
if (submit.length > 0) { if (submit.length > 0) {
submit.attr('disabled', 'disabled'); submit.attr('disabled', 'disabled');
var name = submit.attr('name') ? submit.attr('name') : 'submit'; var name = submit.attr('name') ? submit.attr('name') : 'submit';
......
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