Observers are *added*, not *replaced*. So the second time over, you'll
get add+update, of course.
You need to remove the first observer, which means keeping a reference
to it for later using with Event.stopObserving.
But actually, the simplest road is to NOT use these tricks, and observer
on fSubmit directly, with no parameter. Then have fSubmit look up
$('btnOK').value, and act accordingly. Also avoid inline event handlers
like onclick, which won't work properly on MSIE regarding event object
passing, and are an intrusion of behavior in content:
$('btnOK').observe('click', fSubmit); // Only once, and on onclick= attr
function fSubmit() {
var mode = $('btnOK').value;
if ('Update' == mode)
// ...
else
// ...
}
Of course, this fails when you start localizing the UI, but will you?
--
Christophe Porteneuve a.k.a. TDD
"[They] did not know it was impossible, so they did it." --Mark Twain
Email: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---