Also… with the evalScripts method,
try assigning your functions differently so they stay in memory (assign them as
variables)… myalert = function(txt) { alert(txt); }; Then you should be able to access them… From: Somewhere in your process (not sure where
in your specific case)… try doing the following to inject a script
element into the dom, where url is your .js path… This makes that script
file get executed immediately. var jsScript =
document.createElement("script"); jsScript.setAttribute("type", "text/_javascript_"); jsScript.setAttribute("src", url); var node =
document.body.firstChild; node = (node.nodeType == 3)
? node.nextSibling : node; document.body.insertBefore(jsScript, node); From: I working on rebuilding my CMS software using I am loading up a new component of my system using the Ajax.Updater,
and it loads up the HTML fine but as the component I am loading up is fairly
complicated I want to load up its relevant _javascript_ functions as well at
the same time. I am using the evalScript:true option, and somthing simple like
alert("foobar") gets triggered in my loaded code, but if I try
to define a function and then try to call it like
function myalert(txt)
{
alert(txt)
}
myalert("foobar") It wont get called. But if I move myallert() into my main page I can call the function from
the code loaded by Ajax.Update I would much prefer to have my _javascript_ loaded dynamically
with each different component as needed instead of having to load up everything
when the app is originally loaded. I tryed including the JS code directly in the code returned by
Ajax.Updater as well as linking to it with: <script type="text/_javascript_" src=""> No love. My second problem is probably related. I am using Behaviour.js and would like to have my code loaded by
Ajax.Updater register new rules. Again I have to define them in the main app,
but even worse, if the element the rule is applied to does not exist in the app
in its initial state, the rule doesn't take. Any how, I am sure there is a simple solution to this so your help is
appreciated! ______________________________________________________________________ Alex Duffield . Principal . InControl Solutions . http://www.incontrolsolutions.com The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. |
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs