It's not a perfect solution, but you can use window.onbeforeunload 
(javascript) to check for some condition. The user still has the option 
of leaving, but at least they are notified that something is not right. 
In one app I work on, some "notifications" are collected as the 
administrator makes scheduling changes. We want to send all of the 
notifications at one time, so we let the admin continue to work and 
click a button when ready. In the event that the notifications have not 
been sent when the page unloads, a message pops up to let the admin know 
they haven't finished the process. My JavaScript looks like:

function notifications_check(evt)
{
  if (pending_notifications)
  {
    var message = "There are pending notifications.  By leaving this 
page before sending them, " +
      "you risk losing them completely. Are you sure you want to leave?"
    if (typeof evt == 'undefined')
    {
      evt = window.event;
    }

    if (evt)
    {
      evt.returnValue = message;
    }

    return message;
  }
}

window.onbeforeunload = notifications_check;

Peace.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to