From: Michael Peters Date: Fri, 5 Dec 2014 16:34:21 +0000 (-0500) Subject: LP#1154656 MARC Expert Search "Add Rows" adds duplicate row X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=255108be1428e0530ef1d1b437bed364bab93f4a;p=evergreen%2Fpines.git LP#1154656 MARC Expert Search "Add Rows" adds duplicate row This patch changes the behavior of the "Add Search Row" link (JavaScript function from simple.js "addExpertRow()") so that we are always cloning the initial "empty" row instead of potentially cloning a row -- by way of cloneNode() -- with user input in place, and causing duplicate search rows. Signed-off-by: Michael Peters --- diff --git a/Open-ILS/web/js/ui/default/opac/simple.js b/Open-ILS/web/js/ui/default/opac/simple.js index b4915862a2..7c49b39592 100644 --- a/Open-ILS/web/js/ui/default/opac/simple.js +++ b/Open-ILS/web/js/ui/default/opac/simple.js @@ -13,31 +13,36 @@ function addClass(node, cls) { } function unHideMe(node) { removeClass(node, "hide_me"); } function hideMe(node) { addClass(node, "hide_me"); } +(function($){ -var _search_row_template, _expert_row_template; +var _search_row_template, _expert_row_template, t; +var _el_adv_global_row = $("adv_global_row"), _el_adv_expert_row = $("adv_expert_row"); +if (_el_adv_global_row) { + t = _el_adv_global_row.cloneNode(true); + t.id = null; + _search_row_template = t; +} function addSearchRow() { - if (!_search_row_template) { - t = $("adv_global_row").cloneNode(true); - t.id = null; - _search_row_template = t; - } - $("adv_global_tbody").insertBefore( _search_row_template.cloneNode(true), $("adv_global_addrow") ); } -function addExpertRow() { - if (!_expert_row_template) { - t = $("adv_expert_row").cloneNode(true); - t.id = null; - _expert_row_template = t; - } +if (_el_adv_expert_row) { + t = _el_adv_expert_row.cloneNode(true); + t.id = null; + _expert_row_template = t; +} +function addExpertRow() { $("adv_expert_rows_here").appendChild( _expert_row_template.cloneNode(true) ); } + +window.addSearchRow = addSearchRow; +window.addExpertRow = addExpertRow; +})($); function killRowIfAtLeast(min, link) { var row = link.parentNode.parentNode; if (row.parentNode.getElementsByTagName("tr").length > min)