Well, I'll reply to myself, to see if anybody can help me debug this
code:
I've come up with this:
<script type="text/javascript">
// Definimos la función de hacer cosas...
var FormWatch = Class.create();
FormWatch.prototype = {
initialize : function(form, options) {
this.changed = false;
this.form = $(form);
// We monitor form changes...
new Form.EventObserver(form, this.setChanged.bind(this)
);
// Let's hook main window...
Event.observe(window, 'beforeunload',
this.confirmExit.bind(this),
false);
// And let's hook submit action :) ...
Event.observe(this.form,'submit',this.unsetChanged.bind(this),false);
},
unsetChanged : function(ev) {
this.changed = false;
},
confirmExit : function(ev) {
if (this.changed) {
Event.stop(ev);
}
},
setChanged : function (element, value) {
this.changed = true;
}
}
</script>
And right after the form:
<script type="text/javascript">
new FormWatch('watch_form_1');
</script>
That frankenstein mostly works, 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:
Are you sure you want to exit this page?
false <- this only appears in IE
Click OK to continue, or Cancel to stay in the current page.
That's exactly what I want to achieve, but I wouldn't mind to be able
to control that popup (and get rid of that "false" in IE)...
Help please! I'm almost there!! :)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---