From 3d1ce5cbab5cce631595ded887de99de839c55f1 Mon Sep 17 00:00:00 2001 From: Patricio Marrone Date: Tue, 10 Jan 2017 15:53:33 -0300 Subject: [PATCH] Bug 17817: Fix cloning subfields using select2 Based on Jonathan's patch (the DO NOT PUSH one), I put together this fix. What was changed is that select2 is reinitialized only after the cloned element has been appended to the DOM (so that select2 can correctly calculate the field's width). Also, I changed the selectors that searched for the line divs (for reordering) and for the subfield's input element (for erasing the field's value) to be more specific, since select2 introduced divs that broke some assumptions about the expected HTML structure --- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index ee03961..7514de7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -253,6 +253,10 @@ function CloneField(index, hideMarc, advancedMARCEditor) { */ function CloneSubfield(index, advancedMARCEditor){ var original = document.getElementById(index); //original
+ var original_selects = original.getElementsByTagName('select'); + for( var i=0,len=original_selects.length;i") // getting all subfields for this tag - var subfields = tag.getElementsByTagName('div'); + var subfields = tag.querySelectorAll("div.subfield_line"); var subfieldsLength = subfields.length; if(subfieldsLength<=1) return; // nothing to do if there is just one subfield. @@ -422,8 +432,8 @@ function upSubfield(index) { // among all subfields for(var i=0;i