From: Thomas Berezansky Date: Fri, 28 Sep 2012 19:09:29 +0000 (-0400) Subject: Scoping Issues: Use a function to resolve X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Ftsbere%2Ffix_race_conditions;p=working%2FEvergreen.git Scoping Issues: Use a function to resolve The loop scoping doesn't play nice with the load callback. By wrapping all of that in a function we create a new scope and solve the issue. Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/xul/staff_client/server/circ/circ_summary.xul b/Open-ILS/xul/staff_client/server/circ/circ_summary.xul index 6b7f6fa686..70600cdd89 100644 --- a/Open-ILS/xul/staff_client/server/circ/circ_summary.xul +++ b/Open-ILS/xul/staff_client/server/circ/circ_summary.xul @@ -94,18 +94,21 @@ $('r_last').disabled = false; $('r_all').disabled = false; var gb = $('circs'); - for (var j = 0; j < g.circs.length; j++) { + function addcirc(circid) { var iframe = document.createElement('iframe'); iframe.setAttribute('style','overflow: none; min-height: 100px;'); iframe.setAttribute('flex','1'); gb.appendChild(iframe); var setXulG = function() { - get_contentWindow(iframe).xulG = { 'circ_id' : g.circs[j].id() }; + get_contentWindow(iframe).xulG = { 'circ_id' : circid }; iframe.removeEventListener('load', setXulG, true); }; iframe.addEventListener('load', setXulG, true); iframe.setAttribute('src', urls.XUL_CIRC_BRIEF); // + '?circ_id=' + g.circs[j].id() ); } + for (var j = 0; j < g.circs.length; j++) { + addcirc(g.circs[j].id()); + } } catch(E) { g.error.standard_unexpected_error_alert('error showing circs',E); }