I''m having some trouble getting afterfinish to be called properly. I''m new to scriptaculous and my example is ridiculously simple, so I''m sure it''s just a stupid mistake but after trying half a dozen variations I''m at a loss to see what it is. Hopefully someone here can spot it. Here''s the example: <script type="text/javascript"> function myCallBackOnFinish() { try { alert(''done''); } catch (err) { alert("ERROR: "+err); } } function simpleHighlight(elemToHighlight) { new Effect.Highlight(elemToHighlight, {afterfinish: myCallBackOnFinish }); } </script> <a href="#" onclick=''simpleHighlight(this)''>Highlight me</a> Using that in Firefox 2.0 or in IE 7 (both on XP) causes the link to highlight correctly, but the afterfinish callback function is never called. No errors are reported in FF or Firebug. An error is reported in IE 7 (''target'' is not defined), but I''ll have to dig up an IE7 javascript debugger and install it to get more detail on that. Here are some of the variations I''ve tried: ---------------------------------------------------------------------- function simpleHighlight(elemToHighlight) { new Effect.Highlight(elemToHighlight, {afterfinish: function() {alert(''done'');} }); } function simpleHighlight(elemToHighlight) { new Effect.Highlight(elemToHighlight, {afterfinish: function() {myCallBackOnFinish();} }); } ----------------------------------------------------------------------- Neither of those work. This one almost works: It calls the callback before the highlight begins, rather than after it finishes: function simpleHighlight(elemToHighlight) { new Effect.Highlight(elemToHighlight, {afterfinish: myCallBackOnFinish() }); } I''ve also tried it using Effect.Fade (instead of Effect.Highlight) with the same results - the effect executes but the afterfinish callback function doesn''t. When I step through it in Firebug I do in fact see options.afterfinish in the initialization method of Effect.Highlight. I''m not familiar enough with javascript/Firebug to know how to inspect it to see if it points at myCallBackOnFinish, but it is there and defined. Environment details, in case they turn out to be relevant: Test file loaded from local webapp (e.g. http://localhost:8080/myapp/hello.html) Firefox: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 IE 7: 7.0.5730.11, Update Versions:0 I didn''t see anything in the bugs or this list about this which is another reason I''m assuming it''s a lame mistake on my part. Any assistance is greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/24/07, noah_ten <noah.mercer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having some trouble getting afterfinish to be called properly.It is called "afterFinish". Javascript is case-sensitive. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 24, 12:49 am, "Martin Bialasinski" <klingel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On 1/24/07, noah_ten <noah.mer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m having some trouble getting afterfinish to be called properly. > It is called "afterFinish". Javascript is case-sensitive.Also, if I''m not mistaken, the try...catch block is doing nothing. Try...catch tries the code in try {} and if there''s an error, it''ll catch it and break into that. Well, all you''re doing here is TRYing an alert, which is always be fine, so you''ll never catch an error. Maybe you want to do this as you''ll eventually change the code, but if you were looking to catch an error during the Effect.Highlight, then you''ll need to do something else rather then the try...catch you have. Al --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sigh... I was sure it was something simple, but I didn''t expect it to be quite that simple. Thanks for the catch, Martin - fixing the case did the trick. And yes, Al, the try block is pointless - I originally had something a little more complicated than an alert() in there and I wrapped the try around it just to be sure my code wasn''t causing an error that was getting eaten for some reason. Thanks again, Noah On Jan 23, 5:28 pm, "Al" <alexrussell...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 24, 12:49 am, "Martin Bialasinski" <klingel...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On 1/24/07, noah_ten <noah.mer...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I''m having some trouble getting afterfinish to be called properly. > > It is called "afterFinish". Javascript is case-sensitive.Also, if I''m not mistaken, the try...catch block is doing nothing. > Try...catch tries the code in try {} and if there''s an error, it''ll > catch it and break into that. Well, all you''re doing here is TRYing an > alert, which is always be fine, so you''ll never catch an error. Maybe > you want to do this as you''ll eventually change the code, but if you > were looking to catch an error during the Effect.Highlight, then you''ll > need to do something else rather then the try...catch you have. > > Al--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---