I have a page with some links on it that when clicked, loads a "subpage" in a div. This subpage contains some html and javascript. I see how using ajax.updater with evalscripts will run any standalone javascript on the subpage, but I do not have access to any of the javascript functions on that subpage. Is there some way I can make those javascript functions available to the page? thanks for any help! _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
When defining the functions, store them in variables... myFunc = function() { //...etc... } That SHOULD work, but others have mentioned having to go the extra step of assigning them to the window object (which I''m almost convinced in unnecessary but I don''t use the prototype AJAX stuff - not flexible enough for my needs). So if the above still does not work, try... window.myFunc = function() { //...etc... } ________________________________ From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Aaron Meier Sent: Tuesday, March 14, 2006 9:15 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Returning Javascript I have a page with some links on it that when clicked, loads a "subpage" in a div. This subpage contains some html and javascript. I see how using ajax.updater with evalscripts will run any standalone javascript on the subpage, but I do not have access to any of the javascript functions on that subpage. Is there some way I can make those javascript functions available to the page? thanks for any help! 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
ahh, worked great. thanks for the quick reply! btw, it worked without having to assign to window, at least in FF and IE6 On 3/14/06, Ryan Gahl <Ryan.Gahl-nlycWCgr5/vuufBYgWm87A@public.gmane.org> wrote:> > When defining the functions, store them in variables… > > > > myFunc = function() { > > //…etc… > > } > > > > > > That SHOULD work, but others have mentioned having to go the extra step of > assigning them to the window object (which I''m almost convinced in > unnecessary but I don''t use the prototype AJAX stuff – not flexible enough > for my needs). So if the above still does not work, try… > > > > window.myFunc = function() { > > //…etc… > > } > > > ------------------------------ > > *From:* rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto: > rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] *On Behalf Of *Aaron Meier > *Sent:* Tuesday, March 14, 2006 9:15 AM > *To:* rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > *Subject:* [Rails-spinoffs] Returning Javascript > > > > I have a page with some links on it that when clicked, loads a "subpage" > in a div. This subpage contains some html and javascript. I see how using > ajax.updater with evalscripts will run any standalone javascript on the > subpage, but I do not have access to any of the javascript functions on that > subpage. Is there some way I can make those javascript functions available > to the page? thanks for any help! > > 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
No problem. Keep that window assignment thing in mind though. You might run into a situation where your eval statements are running in the scope of a closure, in which case you might lose those functions if you don''t assign them to some global object. But I think for the most part you''ll be safe with just assigning them to variables. 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
Reasonably Related Threads
- Exception in Javascript console in Firefox 1.0.7
- Yahoo!-like Event object emulation/abstraction in Prototype?
- RE: Yahoo!-like Event object emulation/abstractionin Prototype?
- Ajax.Updater and loading new javascript functions.
- RE: Ajax.Updater and loading new javascriptfunctions.