In my rails project, I want to trigger an event when we close a specific window, let's say I have home view.
I can acheive that by adding something like:
<script type="text/javascript">
$(window).unload(function() {
alert('hey');
});
</script>
to the end of /home/index.html.erb file.
If I move the script to home.js.coffee it will stop from working.
I want to trigger the alert when I close home page, not other pages, how can I achieve that?