Thursday, 2 April 2015

avoid lose data javascript

//from https://github.com/tolk/tolk/
$(function () {
$("#submit").bind("click", function () {
window.onbeforeunload = null;
});
// avoid lose data
$(".translations").bind("keydown", function () {
window.onbeforeunload = confirm;
});
$(".translations").bind("change", function () {
window.onbeforeunload = confirm;
});
function confirm() {
return "You are leaving this page with non-saved data. Are you sure you want to continue?";
}
});
view raw gistfile1.js hosted with ❤ by GitHub

No comments:

Post a Comment