I want to cancel the post update in some circunstances without the need to reload the entire page.
I’ve tried:
// publish is the id of the Update button.
$('#publish').click(function(){
return false;
});
// post is the id of the corresponding form.
$('#post').submit(function(){
return false;
});
In both codes the form it’s not submitted but the Update button remain disabled and the ajax loader gif is showed.
How I can do this? Thanks in advance.
I think because WordPress already has an event handler on that element it doesn’t matter what it returns, it’s just firing both even handlers. Try this:
Did you also try:
Finally, with the help of those who answered my question (specially to stealthyninja), I managed to bring working what I asked.
@karevn: This solution doesn’t break the autosave in current WordPress version (tested up to 3.2.1).
Sorry, it is impossible – it breaks autosave in current WordPress version. You can submit a patch to WP or stick to another solution.