$(document).keydown(function (e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
function_which_does_a_lot_including_ajax_calls();
return false;
}
});
I’m trying to call a method on control+S, and, the call to function_which_does_a_lot_including_ajax_calls() stops the code from reaching the “return false” in time, which means that the browser prompts the default “Do you want to save this website” window.
If I change it to simply:
$(document).keydown(function (e) {
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
// function_which_does_a_lot_including_ajax_calls();
return false;
}
});
… the return false is triggered, and nothing happens (no default prompt).
Is there a way I can do a lot of stuff, but still return false so that the browser does not do its default behavior? Thanks!
I’m not sure I understand the behaviour you described but you can try something like: