I'm having two different problems with a web application I've been
working on, but I'm beginning to think they are related and involve a
bug in using <code>return false;</code> under prototype managed
functions (such as in observe).

The first case is with an observer on certain 'links'. The href target
is simply "#". Before using prototype I found simply returning false
at the end of whatever code I wanted to execute as a result of the
click worked fine in both Firefox and IE to prevent '#' being appended
to the current page's url. However since adding onclick handlers via $
().observe and such using prototype, I noticed that returning false no
longer seemed to suppress the updating of the pages URL. I'm early in
the development stage (I work on Linux and use Firefox as my browser,
just occasionally checking the page with IE from a windows system for
any erorrs). and that was a minor issue so I ignored it for the
moment.

The page I am working on has multiple forms on it, and I use prototype
and css to manage their presentation and workflow. I had a problem
with the behavior of (sub)forms being submitted when the user pressed
the Enter key, as it broke our intended workflow (subform submission
being done via AJAX), so today I added an Event handler to watch for
Enter being pressed within a form. That handler determined the active
form and took the appropriate validation/submission actions just as if
the user had clicked 'next' or whatever in our planned workflow.

The javascript detects the enter key, calls the expected code and
submits via AJAX using the desired function (and its reception is
confirmed on the server). <code>return false;</code> is (I thought)
the last statement executed after all the updates are made, which, I
thought, would suppress the Enter key being otherwise used to submit
the form. However, it then goes ahead and submits it a second time,
breaking the workflow as before.

I have come to believe it is a problem with returning false from a
prototype function under Firefox when, after far too much *head->desk*
I thought I'd go see what happens under IE. ... And for the first time
in ages, everything worked as I expected it under IE while it wasn't
under Firefox! Under IE, not only does enter submit the form and
update the pages workflow as planned, it stops there and does not
submit the page completely as a second event, apparently respecting
the <code>return false;</code>! At that point it occurred to me to
check out the URL, and sure enough, the links through the subforms
submitted for validation and updated the page as desired, without
appending '#' to the URL.

Is this a known bug? If so is there a patch or a workaround? Is it
specific to Firefox 2? Or have I just done something wrong along the
way?

Thanks,
Sean


--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to