Francesco,

As you know, JavaScript executes statements sequentially one after another,
so it isn't generally possible for one line of code to affect another line
of code that's already been executed.

There are two exceptions that I'm aware of:

1) A syntax error will prevent *any* of your code from being executed. But
Firebug will display the error if that's the case.

2) If your DeLorean hits that wire with the connecting hook at precisely
88mph the instant the lightning strikes the tower, all bets are off. Neither
JavaScript nor Firebug can keep up with a speeding DeLorean.

But it doesn't appear that either is the case here. If the only difference
between the two examples is the "return true" vs. "return false", then they
should both be executing the updateMapFromFields() call, or neither one is.
If one is and one isn't, then there must be some other difference between
your two test cases.

Maybe updateMapFromFields() actually is being executed in both cases, but
something is going wrong in the function so it doesn't seem to have the
expected result? Have you put a console.log() call at the beginning of that
function to see if Firebug logs the call?

Rather than speculate on what might be going wrong, how about posting a link
to a test page that demonstrates the problem?

-Mike

> From: gregarious
> 
> Hi,
> 
> I'm trying to perform an action before a form is submitted 
> using the following snippet:
> 
> $('form').submit(function() {
>     updateMapFromFields();
>     return true;
> });
> 
> but for some reasons the updateMapFromFields seems not to be executed.
> If, instead, I execute the following code (with "return false" at the
> end):
> 
> $('form').submit(function() {
>     updateMapFromFields();
>     return false;
> });
> 
> I can see that the updateMapFromFields() works fine but, 
> obviously, the form isn't submitted (while I'd like it to be 
> submitted somehow).
> Am I supposed to do something else in order to perform an 
> action before the form is submitted?
> 
> Thanks a lot for your time, any help would be very appreciated.

Reply via email to