From c10f52578072477dad7c5f4dd73882ccf060ed45 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 17 Nov 2008 00:10:13 +0000 Subject: [PATCH] This fixes Cataloging -> Create New Marc Record in xulrunner 1.9, but illustrates a problem that can probably be found elsewhere in the code. First, a little context. One of the main mechanisms for inter-window communication within the staff client is the "shoving" of data and functions from one context into a foreign context. So, for example, you may have code that looks like this: var test = 'See!'; var w = window.open('some_interface.html'); w.xulG = { 'foreign_data' : 'hey, some_interface.html can make use of me, because xulG is now defined in its context', 'foreign_function' : function() { alert("hey, some_interface.html can call me, but I'm a closure and stay scoped to my original context. Treat me as a callback. " + test) } ); If the window is not modal, then this works. It also works with iframes. var iframe = document.createElement('iframe'); iframe.setAttribute('src','some_interface.html'); iframe.contentWindow.xulG = { 'foo' : 'bar' }; But what stopped working with xulrunner 1.9 is an example similar to the one above, where the iframe already exists. var iframe = document.getElementById('some_iframe'); iframe.setAttribute('src','some_interface.html'); // This now loads asynchronously and does not wait for the current javascript thread to complete iframe.contentWindow.xulG = { 'foo' : 'bar' }; // And so this gets shoved in possibly after the onload event for some_interface.html, or maybe not at all. I'm not sure yet One other mechanism for shoving xulG into a foreign context appears to still work, and that's the progress listener that shoves into browser elements, to preserve xulG during different page loads. git-svn-id: svn://svn.open-ils.org/ILS/trunk@11231 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/xul/staff_client/server/cat/marc_new.xul | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/cat/marc_new.xul b/Open-ILS/xul/staff_client/server/cat/marc_new.xul index 780edc1d0a..c8eb42a6df 100644 --- a/Open-ILS/xul/staff_client/server/cat/marc_new.xul +++ b/Open-ILS/xul/staff_client/server/cat/marc_new.xul @@ -124,9 +124,12 @@ } } }; - $('marc_editor').setAttribute('src',url); + var marc_editor = document.createElement('iframe'); + $('marc_editor_box').appendChild(marc_editor); + marc_editor.setAttribute('flex','1'); + marc_editor.setAttribute('src',url); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - get_contentWindow($('marc_editor')).xulG = params; + get_contentWindow(marc_editor).xulG = params; /* hide template widgets */ $('actions').hidden = true; @@ -155,12 +158,11 @@ - +