[Bug 18183] New: jQuery append error related to script tags in cloneItemBlock
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Bug ID: 18183 Summary: jQuery append error related to script tags in cloneItemBlock Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Acquisitions Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org This is a strange javascript error that I experienced on a 3.22 system and could not reproduce with the current (modified) framework in master. But since the code is essentially the same, it might still be possible. The js error is: TypeError: document.getElementById(...) is null The line in koha-tmpl/intranet-tmpl/prog/js/additem.js that causes this error is: $(clone).append(data); While running append, jQuery seems to call .domManip and .globalEval internally. The result on the interface is that you do not have an item block when receiving an order (AcqCreateItem=receiving). Note that data comes from services/itemrecorddisplay.pl and is a very long string containing all item fields and even script tags for plugins. Between the ACQ framework in 3.22 and in master (copied from Default), I noticed some smaller changes in the lines for plugins. Since the js variable "clone" contains a jQuery object for an element that is not yet added to the page, I could imagine a getElementById error. But it does not always occur, so some other condition must be triggered too. This condition appears to be connected to the script tags, since removing all plugins from the ACQ framework in 3.22 made the error disappear (no solution however). Some interesting comments on jQuery's handling of appending script tags are found in http://stackoverflow.com/questions/610995/cant-append-script-element Triggered by the getElementById error, I rearranged a few lines in cloneItemBlock so that I appended clone (the 'floating' div field for the new item) first to the outeritemblock div on the page and after that I appended the data string (item fields and script tags) to clone. This resolved the js error on 3.22 and did not affect master. Conclusion: We seem to stumble over a problem with our plugin script tags in jQuery's script evaluation when clone is not bound to the page yet. The proposed patch just adds this workaround touching three lines. If we would like to change (again) the way we handle script tags for plugins, we will need much more effort. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 --- Comment #1 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Created attachment 60731 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=60731&action=edit Bug 18183: jQuery append error related to script tags in cloneItemBlock See the detailed explanation of the error on Bugzilla. As a workaround, we move the append of clone to outeritemblock before the append of data (long string with item fields and script tags) to clone. This patch also moves two vars inside the success function, since they are not used outside of it. Test plan: [1] Set AcqCreateItem to receiving. [2] Receive an order. Verify that adding, updating or deleting an item block still works as expected. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |m.de.rooy@rijksmuseum.nl |ity.org | Patch complexity|--- |Small patch -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #60731|0 |1 is obsolete| | --- Comment #2 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Created attachment 67821 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=67821&action=edit Bug 18183: jQuery append error related to script tags in cloneItemBlock See the detailed explanation of the error on Bugzilla. As a workaround, we move the append of clone to outeritemblock before the append of data (long string with item fields and script tags) to clone. This patch also moves two vars inside the success function, since they are not used outside of it. Test plan: [1] Set AcqCreateItem to receiving. [2] Receive an order. Verify that adding, updating or deleting an item block still works as expected. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- (In reply to Katrin Fischer from comment #2)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Thanks. This was pending for some time already. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Josef Moravec <josef.moravec@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |josef.moravec@gmail.com QA Contact|testopia@bugs.koha-communit |josef.moravec@gmail.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Josef Moravec <josef.moravec@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Josef Moravec <josef.moravec@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #67821|0 |1 is obsolete| | --- Comment #4 from Josef Moravec <josef.moravec@gmail.com> --- Created attachment 70224 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=70224&action=edit Bug 18183: jQuery append error related to script tags in cloneItemBlock See the detailed explanation of the error on Bugzilla. As a workaround, we move the append of clone to outeritemblock before the append of data (long string with item fields and script tags) to clone. This patch also moves two vars inside the success function, since they are not used outside of it. Test plan: [1] Set AcqCreateItem to receiving. [2] Receive an order. Verify that adding, updating or deleting an item block still works as expected. Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org Severity|enhancement |normal -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Jonathan Druart <jonathan.druart@bugs.koha-community.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to Master --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- Pushed to master for 18.05, thanks to everybody involved! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com Status|Pushed to Master |Pushed to Stable --- Comment #6 from Nick Clemens <nick@bywatersolutions.com> --- Awesome work all, pushed to stable for 17.11.02 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18183 Fridolin SOMERS <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |fridolin.somers@biblibre.co | |m --- Comment #7 from Fridolin SOMERS <fridolin.somers@biblibre.com> --- Pushed to 17.05.x for v17.05.08 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org