From 981ef7fa8ae452a32c33ae5694c099389a1a228a 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 Content-Type: text/plain; charset=utf-8 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. --- 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 0f93310..6e4bf33 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.1.4