PDA

View Full Version : DHTML Modal onclose dirty check



voracious27
10-18-2010, 05:51 PM
1) Script Title:
DHTML Modal window v1.1

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/dhtmlmodal.htm

3) Describe problem:
I'm having trouble understanding exactly how the X works. When I right click and inspect the element, all I see is an image with no click event and just a Title of "Close". I tried commenting this line in dhtmlmodalwindow.js as I thought this was attaching the click event to this img:
t.controls.onclick = dhtmlwindow.enablecontrols

but the X still works. Basically, I want to be able to intercept the close event (X), check a javascript variable (is the form dirty) and prompt to user with a jquery confirm dialog (Are you sure you want to Proceed?). This is easily being done in non-modal forms by using jQuery to bind to the click event of all <a>'s on the page that could take the user away from a dirty form, checking the flag and letting the event go through if they confirm otherwise cancel. I'm a bit stuck on how I can do something similar with this X. I thought I'd try to make it an <a> so it'd be picked up but need to understand how this event gets wired up. Any pointers would be greatly appreciated.