Events don't get overwritten, you can add multiple events to the same
element.Plus, I think the beforeunload event is what you're looking for.
window.addEvent('beforeunload', function() {
if(MySite.hasToStop) return 'Your document has not been saved.';
});
On Sat, Dec 20, 2008 at 11:33 PM, Oskar Krawczyk
<[email protected]>wrote:
>
> Hi Folks, hope you're well!
>
> Please consider the scenario below:
>
> 1. A user gets a form he might or might not fill.
>
> 2. If a user has modified the field, every link on the webpage should
> get an event applied to itself.
>
> 3. Clicking on one of the links would display a popup (a html one, not
> the alert() thing) asking for confirmation whether we want to leave
> the page without saving or not.
>
> 4. Now, in some cases a link on the page would already have an event
> attached – bummer, it gets overwritten by the new one and we're left
> with out pants down.
>
> You can see my pain. I was considering storing the default event –
> this.store('default:event', e) – but that would clearly work only when
> the actual event gets triggered.
>
> Maybe it's the late hour but I don't see any easy solution to get
> successfully through the scenario.
>
> Any suggestions?
>
> Best,
> Oskar
--
Guillermo Rauch
http://devthought.com