2010-11-13 6 views

Répondre

0

Vous pouvez utiliser l'événement onbeforeunload en javascript, puis utiliser ajax pour appeler l'action de vos rails.

Quelque chose comme ceci:

<script language="JavaScript"> 
window.onbeforeunload = confirmExit; 
function confirmExit() 
{ 
    new Ajax.Request('/some_url', { method:'get' }); 
} 
</script> 

I utilisé Prototype dans cet exemple. Pour en savoir plus à ce sujet: http://www.prototypejs.org/learn/introduction-to-ajax.

+0

Mon application utilise un prototype. Donc, y a-t-il un moyen de remplacer $ .ajax ?? –

+0

Je l'ai changé de jQuery à Prototype. – XIII

Questions connexes