Skip to content

Instantly share code, notes, and snippets.

@kuntoaji kuntoaji/main.js

Last active Dec 28, 2015
Embed
What would you like to do?
Javascript Alert For Unsaved Changes with Turbolinks and Jquery
// ...
change = function() {
$("form input, form textarea").change(function() {
$('a').click(function() {
confirm('Unsaved changes on the page. Are you sure?');
});
});
};
// ...
ready = >
# your jquery code here
# page:load is fired at the end of the loading process.
$(document).ready(ready)
$(document).on('page:load', ready)
change = ->
$("form input, form textarea").change( ->
$('a').click( ->
confirm('Unsaved changes on the page. Are you sure?')
)
)
$(document).ready(change)
# the page has been parsed and changed to the new version and on DOMContentLoaded
$(document).on('page:change', change)
@fabricioflores

This comment has been minimized.

Copy link

fabricioflores commented Feb 13, 2014

Hi. Thanks for the ideas... But It doesn't work in my project. I also tried with page:before-change event but i can't make it work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.