<p align=\"left\"><b><font face=\"Arial\" size=\"2\">GFI MailSecurity''s HTML threat engine found HTML scripts in this email and has disabled them.</font></b></p>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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ryan Gahl Sent: Friday, February 17, 2006 2:08 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] Ajax.Updater and loading new javascriptfunctions. 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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield Sent: Friday, February 17, 2006 2:01 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater and loading new javascript functions. I working on rebuilding my CMS software using AJAX, and have run into a couple problems I cant seem to find the solution to. 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: <Xcript type="text/javascript" src="/path/to/my_new_script.js"></Xcript> 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 <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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
<p align=\"left\"><b><font face=\"Arial\" size=\"2\">GFI MailSecurity''s HTML threat engine found HTML scripts in this email and has disabled them.</font></b></p>Greg beat me to that one... sorry for the duplicate post =) ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Gregory Hill Sent: Friday, February 17, 2006 2:10 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] Ajax.Updater and loading new javascriptfunctions. Well, for inserting a js file after the page is rendered, you have to do it with the DOM. But, according to notes in scriptaculous.js, this does not work in Safari. The way you tried to do it, by putting the src in your script tag, simply won''t work (evalScripts strips out the script tags and evals what''s inside). You could try this: var myalert = function(txt) { alert(txt); }; Then see if you can call it afterwards. I imagine it would work fine, but I''m not speaking from experience on that :-) Greg ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield Sent: Friday, February 17, 2006 1:01 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater and loading new javascript functions. I working on rebuilding my CMS software using AJAX, and have run into a couple problems I cant seem to find the solution to. 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: <Xcript type="text/javascript" src="/path/to/my_new_script.js"></Xcript> 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 <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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Yep, I have all my javascript in separate .js "class" files too (no spaghetti markup mixed with javascript). In fact, I use the below script injection method in place of the XMLHTTP object completely. It''s faster and has a smaller memory footprint, plus absolutely no need for the slow eval() statement. _____ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield Sent: Friday, February 17, 2006 2:34 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Ajax.Updater and loading new javascriptfunctions. Ryan, this I like this solution, as I would much prefer my JS to be in external .js files. assigning the functions to variables also worked great so I heve a few options Thanks! (Thanks to Todd and Gregory as well!!! ) ______________________________________________________________________ Alex Duffield . Principal . InControl Solutions . http://www.incontrolsolutions.com <http://www.incontrolsolutions.com/> On 17-Feb-06, at 12:08 PM, Ryan Gahl wrote: 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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield Sent: Friday, February 17, 2006 2:01 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Ajax.Updater and loading new javascript functions. I working on rebuilding my CMS software using AJAX, and have run into a couple problems I cant seem to find the solution to. 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="/path/to/my_new_script.js"></script> 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 <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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Cool. You wouldn''t happen to know a solution to trying to register new Behaviour rules in the new .js file? I tryed var tabrules = { ''#tabs li a'' : function(element){ element.onclick = function(){ alert("You clicked a tab") } } } Behaviour.register(tabrules); With no love. I would much prefer not to have to stick a bunch of onClicks all over my HTML.. ______________________________________________________________________ Alex Duffield . Principal . InControl Solutions . http:// www.incontrolsolutions.com On 17-Feb-06, at 12:39 PM, Ryan Gahl wrote:> Yep, I have all my javascript in separate .js “class” files too (no > spaghetti markup mixed with javascript). > > > > In fact, I use the below script injection method in place of the > XMLHTTP object completely. It’s faster and has a smaller memory > footprint, plus absolutely no need for the slow eval() statement. > > > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- > spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield > Sent: Friday, February 17, 2006 2:34 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Ajax.Updater and loading new > javascriptfunctions. > > > > Ryan, this I like this solution, as I would much prefer my JS to > be in external .js files. > > > > assigning the functions to variables also worked great so I heve a > few options > > > > Thanks! > > > > (Thanks to Todd and Gregory as well!!! ) > > ______________________________________________________________________ > Alex Duffield . Principal . InControl Solutions . http:// > www.incontrolsolutions.com > > > > > > On 17-Feb-06, at 12:08 PM, Ryan Gahl wrote: > > > > > 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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- > spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield > Sent: Friday, February 17, 2006 2:01 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Ajax.Updater and loading new javascript > functions. > > > > I working on rebuilding my CMS software using AJAX, and have run > into a couple problems I cant seem to find the solution to. > > > > 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="/path/to/my_new_script.js"></ > script> > > > > 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I solved this one so Ill answer my own question incase someone goes searching the same problem... you just need to add Behaviour.apply() after registering them. var tabrules = { ''#tabs li a'' : function(element){ element.onclick = function(){ WCMS_tabs(this); } } } Behaviour.register(tabrules); Behaviour.apply(); ______________________________________________________________________ Alex Duffield . Principal . InControl Solutions . http:// www.incontrolsolutions.com On 17-Feb-06, at 12:57 PM, Alex Duffield wrote:> Cool. You wouldn''t happen to know a solution to trying to register > new Behaviour rules in the new .js file? > > I tryed > > var tabrules = { > > ''#tabs li a'' : function(element){ > element.onclick = function(){ > alert("You clicked a tab") > } > } > } > > Behaviour.register(tabrules); > > > With no love. > > I would much prefer not to have to stick a bunch of onClicks all > over my HTML.. > > > ______________________________________________________________________ > Alex Duffield . Principal . InControl Solutions . http:// > www.incontrolsolutions.com > > > > On 17-Feb-06, at 12:39 PM, Ryan Gahl wrote: > >> Yep, I have all my javascript in separate .js “class” files too >> (no spaghetti markup mixed with javascript). >> >> >> >> In fact, I use the below script injection method in place of the >> XMLHTTP object completely. It’s faster and has a smaller memory >> footprint, plus absolutely no need for the slow eval() statement. >> >> >> >> From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- >> spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield >> Sent: Friday, February 17, 2006 2:34 PM >> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> Subject: Re: [Rails-spinoffs] Ajax.Updater and loading new >> javascriptfunctions. >> >> >> >> Ryan, this I like this solution, as I would much prefer my JS to >> be in external .js files. >> >> >> >> assigning the functions to variables also worked great so I heve a >> few options >> >> >> >> Thanks! >> >> >> >> (Thanks to Todd and Gregory as well!!! ) >> >> _____________________________________________________________________ >> _ >> Alex Duffield . Principal . InControl Solutions . http:// >> www.incontrolsolutions.com >> >> >> >> >> >> On 17-Feb-06, at 12:08 PM, Ryan Gahl wrote: >> >> >> >> >> 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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails- >> spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Alex Duffield >> Sent: Friday, February 17, 2006 2:01 PM >> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> Subject: [Rails-spinoffs] Ajax.Updater and loading new javascript >> functions. >> >> >> >> I working on rebuilding my CMS software using AJAX, and have run >> into a couple problems I cant seem to find the solution to. >> >> >> >> 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="/path/to/my_new_script.js"></ >> script> >> >> >> >> 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> >> >> 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs