jQuery preventDefault Not Behaving
<p>I have a simple search function that is misbehaving. The search box is inside of a form that we do not want to submit when searching, so I have the setup below.</p>

<pre><code>$(function() {
    jQuery.fn.onEnter = function(callback) {
        this.keyup(function(e) {
            if(e.keyCode == 13) {
                e.preventDefault();
                //e.stopPropagation();
                if (typeof callback == 'function')
                    callback.apply(this);
            }
        });
        return this;
    }
    $('#txtSearch').onEnter(function() {
        search();
        return false;
    });
    $('#search_btn').click(function() {
        search();
        return false;
    });

    function search() {
        alert('searching');
    }
});
</code></pre>

<p>The e.preventDefault() line isn't working, so the search function fires as well as the form submits. I've tried it with both <code>e.preventDefault()</code> and <code>e.stopPropagation()</code> with no luck.</p>
