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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---