Since you're updating the contents of an existing element you can both make use of Ajax.Updater
and set it's evalScripts
option. The script tag that gets inserted will be evaluated in the scope of the Ajax.Updater
, meaning it can access functions that are global but not ones that are local to the script which started the update.
Edit:
You want a function contained in the script tag to exist in global scope. Instead of this:
function somefunc() { ...
You need to do it this way:
somefunc = function() { ...
And definitely don't use var
as that prevents somefunc
becoming a global variable. Later, when a button is clicked it's onclick event executes in global scope where somefunc
now resides.