The way I do it is by declaring a global variable like
var myFunction;
and than load the script within another function:
function loadAndRunScript() {
var x = cocoon.request.get("id");
cocoon.load("foo"+x+".js");
myFunction();
}The loaded Script looks like:
myFunction = function() {
cocoon.sendPage("somePipeline", bizData);
}Prior to 2.1.7 it used to work like:
function myFunction() {
cocoon.sendPage("somePipeline", bizData);
}But now the hack with global variable seems to be necessary (don't know exactly why, some scoping changes I guess).
Another way may be http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106269832307956&w=2 But I didn't try that.
HTH Guido
WeeZard wrote:
REPOST
-----------------------------------------------------------------------------------------------
I got some test.js javascript file with this in it:
var x = cocoon.request.get("id"); cocoon.load("foo"+x+".js");
When i run test.js for the first time, it works fine. Script engine reads id
request parameter and loads apropriate foo*.js file.
But when i reload the page with a different id request parameter, script
engine just ignores that, and keeps loading previous foo*.js file.
For example, my first request: myPage.html?id=1 loads foo1.js, my second request: myPage.html?id=2 loads foo1.js, instead of foo2.js !!
Why this isn't working as it should and is there ANY way to dynamicaly load external javascript files
Weez
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Freundliche Gr��e / With kind regards Guido Casper
S&N AG Competence Center Open Source Klingenderstr. 5 D 33100 Paderborn
voice +49 5251/1581-87 fax +49 5251/1581-71 eMail [EMAIL PROTECTED] Web http://www.s-und-n.de
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
