I have a textbox and I want it to show an alert when leaving the page with unsaved changes, except if you click the submit button. This works great, except it still alerts you if the submit button is pressed and I really have no idea how to fix it.
I have 2 files, my Set.js to take the actions of the BBcode, and my script.js
script.js
$(document).ready(function() {
var saveClicked = false;
$(window).bind('beforeunload', function() {
if(y != $("#markItUp").val()) {
if(!saveClicked) {
return 'You have unsaved changes!';
}
}
});
});
Set.js
{
name: 'Save',
className:"miu-save",
call: function() {
$('form#edit').submit();
saveClicked = true;
}
},