2009-01-05

Form Ajax upload with Opera

It looks like Opera hates having its forms disabled. Suppose you have a form with onSubmit handler attached to it using HTML.
<form action="..." onSubmit="return myHandler(this);">
and myHandler looks like that:
/*
form is the first argument to handler
the very form being submitted
*/
form.disable();
new Ajax.Request(form.action,{
 method: 'post',
 parameters: {
  username: $('loginFormUsername').value,
  password: $('loginFormPassword').value
 },
 onSuccess: this.loginSuccess.bind(this)
});
return false;
The code works fine in FF, Chrome ans Safari, but breaks in Opera. It seems that disabling the form in onSubmit handler somehow triggers its normal submission, although handler returns false. The only solution I found is to conditionalize the disabling of form:
if (!Prototype.Browser.Opera) {
 form.disable();
}
How do you manage such a problem?

Комментариев нет: