On Nov 13, 5:29 pm, ditman <[EMAIL PROTECTED]> wrote:
> On Nov 13, 4:13 am, RobG <[EMAIL PROTECTED]> wrote:
>
> > On Nov 13, 3:30 am, ditman <[EMAIL PROTECTED]> wrote:
>
> > >, but when I try to exit a page that has
> > > changed, Event.stop(ev) gets called and a generic IE/Firefox window
> > > pops up asking something like:
>
> > I don't see any window at all.
>
> > --
> > Rob
>
> Hi there!
>
> I've tested that script in IE / Firefox, and it does show a window.
>
> Try this html:
>
> <form id="watch_me">
> <input type="text" id="thing1" name="thing1" value="" /><br />
> <input type="text" id="thing2" name="thing2" value="" /><br />
> <input type="text" id="thing3" name="thing3" value="" />
>  <input type="submit" value=" SUBMIT " />
> </form>
> <script type="text/javascript">
>      new FormWatch('watch_me');
> </script>
>
> > What do you mean by "mostly works"?  I can see that the initialize and
> > confirmExit methods are called, but that's it.  I am not prevented
> > from leaving a modified page at all.
>
> If the form has changed,

Not exactly.   Form.EventObserver attaches your function to the change
event of some form controls and the click event of checkboxes and
radio buttons (because of how IE handles the change event for these
elements I'd guess).  So if you change the form or click any checkbox
or radio, then set the form back to its unchanged state (say using
reset or just changing it back) your function thinks the form has
changed.

It seems problematic whether it works when the page has been reloaded
or radio buttons are involved.


> the script calls Event.stop(ev); Which I
> thought it was enough to "stop" the event from happening...

Returning false from the prompt is sufficient.    I can't see that a
beforeunload event on the window has anywhere to propagate to.  :-)


> That's the
> line that pops up a standard window (the same that will pop up if you
> click here in a link while composing a reply, but instead of saying
> "Your reply message has not been sent", it says "null" in IE, and
> nothing at all in Firefox).
>
> >  I don't see how you determine whether the form has actually changed or not.
>
> new Form.EventObserver(form, this.setChanged.bind(this) );   I think
> that line does the trick...

No, it doesn't.  It just adds the setChange function as a handler for
the change and click events as noted above.  It doesn't actually check
if the form has changed from its default.


--
Rob


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to