Search

Thursday, September 13, 2007

Disabling Forms with Prototype - Gotcha

I love using Prototype for all my JavaScript needs. Ajax calls are real easy with or without parameters. To get some form parameters to pass with your request, you would simply do:
var params = $('myForm').serialize();
and then you would disable the form like so:
$('myForm').disable();
However, here is a little gotcha I always seem to forget:
  • DO NOT disable the form before you read your form values
If you do, code such as:
$F('myFormFiled');
or
$('myForm').serialize();
will no longer work. By not working, I mean will just return empty and you will be beating your head against the desk.
// //]]>