Can submit event be cancelled?
<p>I want to stop form from being submitted, and do something else instead (<code>window.location.href</code> redirect to pretty-printed URL). But I cannot even get the basic part of preventing form from submitting.</p>

<p>As far as I understand it something like this should work:</p>

<pre><code>$(function($){
  $("#search_form").submit(function(e){
    console.log("cancelling submit");
    return false;
  });
});
</code></pre>

<p>I also tried <code>e.preventDefault()</code>, <code>e.stopPropagation()</code>, and various combinations of these. <code>"cancelling submit"</code> gets printed on Firebug console (so the event fires), but the form submits regardless, whatever I do.</p>

<p>jQuery documentation and logic imply that it should work, but it doesn't. Am I doing something wrong?</p>

<p>Hooking to click event might be easier but forms can be submitted in multiple ways - clicking buttons, pressing Enter, and probably something else I haven't thought about, so I'm trying to just take submit event.</p>

<p>I'm testing it all in Firefox.</p>

<p>EDIT: It turned out that <code>&lt;button type='submit' onclick='this.form.submit()'&gt;Search&lt;/button&gt;</code> was causing this. It seems silly in retrospect. Thanks to everyone for help.</p>
