Bug 7350: In neworderempty.pl duplicating an item does not preserve select box selections
cloneNode() does not preserve select box selections, I have created a function to duplicate them : "clone_with_selected".
It is included in "cloneItemBlock", that's all.
Now the values selected in ddl are duplicated as the imput-texts are.
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
(cherry picked from commit a47f59f72f)
Signed-off-by: Chris Nighswonger <chris.nighswonger@gmail.com>
This commit is contained in:
parent
f50e1ec348
commit
d3462cdf80
|
|
@ -6,7 +6,7 @@ function deleteItemBlock(index) {
|
|||
}
|
||||
function cloneItemBlock(index) {
|
||||
var original = document.getElementById(index); //original <div>
|
||||
var clone = original.cloneNode(true);
|
||||
var clone = clone_with_selected(original)
|
||||
var random = Math.floor(Math.random()*100000); // get a random itemid.
|
||||
// set the attribute for the new 'div' subfields
|
||||
clone.setAttribute('id',index + random);//set another id.
|
||||
|
|
@ -55,6 +55,19 @@ function check_additem() {
|
|||
// duplicates within the form.
|
||||
return success;
|
||||
}
|
||||
|
||||
function clone_with_selected (node) {
|
||||
var origin = node.getElementsByTagName("select");
|
||||
var tmp = node.cloneNode(true)
|
||||
var selectelem = tmp.getElementsByTagName("select");
|
||||
for (var i=0; i<origin.length; i++) {
|
||||
selectelem[i].selectedIndex = origin[i].selectedIndex;
|
||||
}
|
||||
origin = null;
|
||||
selectelem = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".cloneItemBlock").click(function(){
|
||||
var clonedRow = $(this).parent().parent().clone(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue