[Koha-bugs] [Bug 35062] New: addbiblio: Allow a framework plugin to add class to prevent submit during ajax call
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Mon Oct 16 12:02:34 CEST 2023
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=35062
Bug ID: 35062
Summary: addbiblio: Allow a framework plugin to add class to
prevent submit during ajax call
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P5 - low
Component: Cataloging
Assignee: koha-bugs at lists.koha-community.org
Reporter: m.de.rooy at rijksmuseum.nl
QA Contact: testopia at bugs.koha-community.org
CC: m.de.rooy at rijksmuseum.nl
I have a plugin that does a REST API call wrapped in an ajax construct:
jQuery.ajax({ rest api stuff }).done(function() ...).fail(function() ...);
Rapidly clicking Save (while the ajax is triggered by the Change event) lets
the plugin shortly show an error before the form submits. Which is obviously
undesirable.
If we would replace this in addbiblio.tt:
var onOption = function () {
- return Check();
+ if ( $('.plugin-blocks-submit').length==0 ) return Check();
}
We can conditionally and temporarily block submittal.
When the change event of the plugin fires, I add class plugin-no-submit to the
html element involved. In the done and fail functions I remove the class again
from the element.
This effectively works. While several other approaches in addbiblio failed.
(Removing the event handler is just too late.)
This is a one-liner that will do the job. On bug 34860 I will still submit a
ISBN/ISSN plugin using this class that will demonstrate its use. In the
meantime this is a harmless check.
--
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.
More information about the Koha-bugs
mailing list