I see, learn and rediscover… everyday!


This is one of the question you find being asked when browse for around 10-15 minutes.
“Your message has not been sent.
Discard your message?” from Gmail.

“Are you sure you want to navigate from this page?
Your message has not been sent.
Press OK to continue, Cancel to stay on the current Page” from Gmail

“Are you sure you want to navigate from this page?
If you leave, your Meebo IM sessions will not be preserved!
Press OK to continue or Cancel to stay on the current page” from meebo

“Are you sure you want to navigate from this page?
You have unsaved changes.
Press OK to continue,or Cancel to stay on the current page” from blogger

Well, what’s common among all 4 of these are that they ask for a confirmation to do some action. This is done generally to prevent losing by data when you click at some link by mistake.

For a web developer, this is one of the simplest thing to code. Javascript provides an inbuilt confirm function. Note that this function always has OK and Cancel button. So we should frame our question to suit these two buttons.

I had a bigger headache when i tried to have this feature in my small map application.
Finally after more than 2 weeks, got how to do this thing without storing it in cookie and doing all other complicated things. I know this is not a great news, but this is really important news for just two souls who don’t mind partying for a week just to celebrate this. 🙂

Anyway, here is the link to the file that helped me in finding out the order of events and choosing which one might work.

After a few clicking and clearing markers, this is the order i decided to do.

infoWindowBeforeClosed is called before an infoWindow is closed. In this function all the form details are stored into Javascript variables.
infoWindowClosed is called after an infoWindow is closed. Here I ask whether the user wants to continue discarding his details or stay with current infowindow
whatever he chooses, the infowindow will be closed. But I’ll create a new infoWindow at the same point with all those details he already provided with. Hmmmm, i do wish we had callbacks like we have in GTK 😉

Two things to note here.
1. After reading so much about events, now creating a marker with an infowindow at the initial position is so easy. Don’t know why I was so scared about this sometime back 😉
2. Don’t know why I started thinking about cookies when I can store anything and everything I want to store in javascript variables :-(. Sometimes I do think like an idiot 😛

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.