This is the script I''m using to fade current content of targetDiv, update content with ajax, then fade in the new content - function a() { new Effect.Fade("targetDiv"); setTimeout(dimmer, 2000); } function dimmer() { var url = "test1.html" var myAjax = new Ajax.Updater( "targetDiv", url, {method: ''get'', onSuccess: function ap() { new Effect.Appear("targetDiv"); } } ); } <div id="container"> <a href="#" onclick="a()"; true false;>hello</a> <div id="targetDiv"> <p>This is where the target lives!</p> </div> </div> This works fine for me. But What I want to be able to do is pass the url in an argument at the onclick - <a href="#" onclick="a("test.html")"; true false;>hello1</a> So that I can use the same script for multiple links updating the - var url = "test1.html" to what ever url i pass it based on the link that is clicked. ie - <a href="#" onclick="a("test1.html")"; true false;>hello1</a> <a href="#" onclick="a("test2.html")"; true false;>hello2</a> <a href="#" onclick="a("test3.html")"; true false;>hello3</a> I know there must be a simple way of doing this. Please advise. Thank you kindly, jacob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-May-28 19:11 UTC
Re: Please Advise...quick question regarding url and ajax.Updater
Wouldn''t something like this work? function a(url) { new Effect.Fade("targetDiv"); setTimeout(function() {dimmer(url);}, 2000); } function dimmer(url) { .... } TAG On May 28, 2007, at 12:28 PM, jg wrote:> > This is the script I''m using to fade current content of targetDiv, > update content with ajax, then fade in the new content - > function a() > { > new Effect.Fade("targetDiv"); > setTimeout(dimmer, 2000); > } > function dimmer() > > { > var url = "test1.html" > var myAjax = new Ajax.Updater( > "targetDiv", > url, > {method: ''get'', onSuccess: function ap() { > new Effect.Appear("targetDiv"); > } > } > ); > } > > <div id="container"> > <a href="#" onclick="a()"; true false;>hello</a> > <div id="targetDiv"> > <p>This is where the target lives!</p> > </div> > </div> > > This works fine for me. But What I want to be able to do is pass the > url in an argument at the onclick - > > <a href="#" onclick="a("test.html")"; true false;>hello1</a> > > So that I can use the same script for multiple links updating the - > var url = "test1.html" to what ever url i pass it based on the link > that is clicked. > ie - > <a href="#" onclick="a("test1.html")"; true false;>hello1</a> > <a href="#" onclick="a("test2.html")"; true false;>hello2</a> > <a href="#" onclick="a("test3.html")"; true false;>hello3</a> > > I know there must be a simple way of doing this. > Please advise. > Thank you kindly, > jacob > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Jesse Farmer
2007-May-28 19:17 UTC
Re: Please Advise...quick question regarding url and ajax.Updater
There is no reason to be using setTimeout since all effects have an afterComplete callback. On 5/28/07, Tom Gregory <tomg-PGZyUNKar/Q@public.gmane.org> wrote:> > Wouldn''t something like this work? > > function a(url) { > new Effect.Fade("targetDiv"); > setTimeout(function() {dimmer(url);}, 2000); > } > > function dimmer(url) { > .... > } > > TAG > > On May 28, 2007, at 12:28 PM, jg wrote: > > > > > This is the script I''m using to fade current content of targetDiv, > > update content with ajax, then fade in the new content - > > function a() > > { > > new Effect.Fade("targetDiv"); > > setTimeout(dimmer, 2000); > > } > > function dimmer() > > > > { > > var url = "test1.html" > > var myAjax = new Ajax.Updater( > > "targetDiv", > > url, > > {method: ''get'', onSuccess: function ap() { > > new Effect.Appear("targetDiv"); > > } > > } > > ); > > } > > > > <div id="container"> > > <a href="#" onclick="a()"; true false;>hello</a> > > <div id="targetDiv"> > > <p>This is where the target lives!</p> > > </div> > > </div> > > > > This works fine for me. But What I want to be able to do is pass the > > url in an argument at the onclick - > > > > <a href="#" onclick="a("test.html")"; true false;>hello1</a> > > > > So that I can use the same script for multiple links updating the - > > var url = "test1.html" to what ever url i pass it based on the link > > that is clicked. > > ie - > > <a href="#" onclick="a("test1.html")"; true false;>hello1</a> > > <a href="#" onclick="a("test2.html")"; true false;>hello2</a> > > <a href="#" onclick="a("test3.html")"; true false;>hello3</a> > > > > I know there must be a simple way of doing this. > > Please advise. > > Thank you kindly, > > jacob > > > > > > > > > > > >-- Jesse E.I. Farmer e: jesse-h8Qh2m8E5SHQT0dZR+AlfA@public.gmane.org w: http://20bits.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
jg
2007-May-28 20:15 UTC
Re: Please Advise...quick question regarding url and ajax.Updater
Okay thanks guys, I will look into ditching the setTimeout and just use the afterComplete callback instead. cheers, jg On May 28, 12:17 pm, "Jesse Farmer" <farme...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> There is no reason to be using setTimeout since all effects have an > afterComplete callback. > > On 5/28/07, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: > > > > > > > Wouldn''t something like this work? > > > function a(url) { > > new Effect.Fade("targetDiv"); > > setTimeout(function() {dimmer(url);}, 2000); > > } > > > function dimmer(url) { > > .... > > } > > > TAG > > > On May 28, 2007, at 12:28 PM, jg wrote: > > > > This is the script I''m using to fade current content of targetDiv, > > > update content with ajax, then fade in the new content - > > > function a() > > > { > > > new Effect.Fade("targetDiv"); > > > setTimeout(dimmer, 2000); > > > } > > > function dimmer() > > > > { > > > var url = "test1.html" > > > var myAjax = new Ajax.Updater( > > > "targetDiv", > > > url, > > > {method: ''get'', onSuccess: function ap() { > > > new Effect.Appear("targetDiv"); > > > } > > > } > > > ); > > > } > > > > <div id="container"> > > > <a href="#" onclick="a()"; true false;>hello</a> > > > <div id="targetDiv"> > > > <p>This is where the target lives!</p> > > > </div> > > > </div> > > > > This works fine for me. But What I want to be able to do is pass the > > > url in an argument at the onclick - > > > > <a href="#" onclick="a("test.html")"; true false;>hello1</a> > > > > So that I can use the same script for multiple links updating the - > > > var url = "test1.html" to what ever url i pass it based on the link > > > that is clicked. > > > ie - > > > <a href="#" onclick="a("test1.html")"; true false;>hello1</a> > > > <a href="#" onclick="a("test2.html")"; true false;>hello2</a> > > > <a href="#" onclick="a("test3.html")"; true false;>hello3</a> > > > > I know there must be a simple way of doing this. > > > Please advise. > > > Thank you kindly, > > > jacob > > -- > Jesse E.I. Farmer > e: j...-h8Qh2m8E5SHQT0dZR+AlfA@public.gmane.org > w:http://20bits.com--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-May-29 03:38 UTC
Re: Please Advise...quick question regarding url and ajax.Updater
Doh, you''re right. I was answering the wrong question (how to pass in an argument) rather than just simplifying the whole process. FWIW jg, the complete list of callbacks is here: http://wiki.script.aculo.us/scriptaculous/show/CoreEffects TAG On May 28, 2007, at 1:17 PM, Jesse Farmer wrote:> > There is no reason to be using setTimeout since all effects have an > afterComplete callback. > > On 5/28/07, Tom Gregory <tomg-PGZyUNKar/Q@public.gmane.org> wrote: >> >> Wouldn''t something like this work? >> >> function a(url) { >> new Effect.Fade("targetDiv"); >> setTimeout(function() {dimmer(url);}, 2000); >> } >> >> function dimmer(url) { >> .... >> } >> >> TAG >> >> On May 28, 2007, at 12:28 PM, jg wrote: >> >>> >>> This is the script I''m using to fade current content of targetDiv, >>> update content with ajax, then fade in the new content - >>> function a() >>> { >>> new Effect.Fade("targetDiv"); >>> setTimeout(dimmer, 2000); >>> } >>> function dimmer() >>> >>> { >>> var url = "test1.html" >>> var myAjax = new Ajax.Updater( >>> "targetDiv", >>> url, >>> {method: ''get'', onSuccess: function ap() { >>> new Effect.Appear("targetDiv"); >>> } >>> } >>> ); >>> } >>> >>> <div id="container"> >>> <a href="#" onclick="a()"; true false;>hello</a> >>> <div id="targetDiv"> >>> <p>This is where the target lives!</p> >>> </div> >>> </div> >>> >>> This works fine for me. But What I want to be able to do is pass the >>> url in an argument at the onclick - >>> >>> <a href="#" onclick="a("test.html")"; true false;>hello1</a> >>> >>> So that I can use the same script for multiple links updating the - >>> var url = "test1.html" to what ever url i pass it based on the link >>> that is clicked. >>> ie - >>> <a href="#" onclick="a("test1.html")"; true false;>hello1</a> >>> <a href="#" onclick="a("test2.html")"; true false;>hello2</a> >>> <a href="#" onclick="a("test3.html")"; true false;>hello3</a> >>> >>> I know there must be a simple way of doing this. >>> Please advise. >>> Thank you kindly, >>> jacob >>> >>> >>>> >> >> >>> >> > > > -- > Jesse E.I. Farmer > e: jesse-h8Qh2m8E5SHQT0dZR+AlfA@public.gmane.org > w: http://20bits.com > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---