From 8386f544b1bf68891b0ce2f68741e9d0115a0d49 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 28 Feb 2017 14:26:22 +0100 Subject: [PATCH] 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 Signed-off-by: Josef Moravec Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- koha-tmpl/intranet-tmpl/prog/js/additem.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/additem.js b/koha-tmpl/intranet-tmpl/prog/js/additem.js index 0f93310a5c..6e4bf33444 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/additem.js +++ b/koha-tmpl/intranet-tmpl/prog/js/additem.js @@ -161,8 +161,6 @@ function cloneItemBlock(index, unique_item_fields, callback) { } } - var random = Math.floor(Math.random()*100000); // get a random itemid. - var clone = $("
") $.ajax({ url: "/cgi-bin/koha/services/itemrecorddisplay.pl", dataType: 'html', @@ -171,6 +169,9 @@ function cloneItemBlock(index, unique_item_fields, callback) { }, success: function(data, textStatus, jqXHR) { /* Create the item block */ + var random = Math.floor(Math.random()*100000); // get a random itemid. + var clone = $("
", { id: 'itemblock'+random }); + $("#outeritemblock").append(clone); $(clone).append(data); /* Change all itemid fields value */ $(clone).find("input[name='itemid']").each(function(){ @@ -209,7 +210,6 @@ function cloneItemBlock(index, unique_item_fields, callback) { } }); - $("#outeritemblock").append(clone); if (typeof callback === "function"){ var cloneIndex = "itemblock"+random; callback(cloneIndex); -- 2.39.5