Forum: Rails Spinoffs (closed, excessive spam) strange fire custom event

04d2c0f820680bc89a258fd7380edd56?d=identicon&s=25 绝路 (Guest)
on 2008-06-18 03:51
(Received via mailing list)
im not good in English, so code here

-----------------------------------------------------------------------------------------------------
<form id="form">
  <input type="submit" value="submit" />
</form>
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/
prototype.js"></script>
<script>

//i pass the submit event with custom event
$('form').observe('submit', function(e){
  $('form').fire('custom:readySubmit', {submitEvent: e})
})

//i expect the submit event will be stop
$('form').observe('custom:readySubmit', function(e){
  e.memo.submitEvent.stop();
})


</script>
-----------------------------------------------------------------------------------------------------
Firefox show as i expect, but IE7 doesn't
im not sure what's the reason or it is a bug.
so someone can give me a help?
F490e41cd5de1393a9f6958b70dae6ab?d=identicon&s=25 Frederick Polgardy (Guest)
on 2008-06-18 15:59
(Received via mailing list)
What is it that you expect, that IE isn't doing?

My guess is that you want the custom observer for readySubmit to stop
the
submit event.  But since the .fire() happens asynchronously (someone
correct
me if I'm wrong here?), the form will submit right away and the custom
handler won't even be called.  Or at the very least, you're getting into
a
very unpredictable timing scenario.  You should really stop the original
submit event in the original handler, or in an ordinary function call
that's
guaranteed to be synchronous.

-Fred

On Tue, Jun 17, 2008 at 8:51 PM, 绝路 <aeoluszzf@gmail.com> wrote:

> "></script>
> })
>
>
> </script>
>
> 
-----------------------------------------------------------------------------------------------------
> Firefox show as i expect, but IE7 doesn't
> im not sure what's the reason or it is a bug.
> so someone can give me a help?


--
Science answers questions; philosophy questions answers.
This topic is locked and can not be replied to.