Hey all
I'd like to trigger an action from my rails controller when the user leaves a page. I fell onto the window.beforeunload event, but I don't know how I can call the function from my controller from the view. I have something like this:
//function that checks if someone leaves the page
//if so, send mail to admin with unconfirmed reservation
function goodbye(e) {
//:action => do_something
}
window.onbeforeunload= goodbye;
Can someone help me? Thanks!