Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Filterable: Prevent form submission
Browse files Browse the repository at this point in the history
Intercept ENTER on keydown and preventDefault()

Fixes gh-7240
  • Loading branch information
Gabriel Schulhof committed Mar 13, 2014
1 parent 4434822 commit 3d96d67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/widgets/filterable.js
Expand Up @@ -161,6 +161,7 @@ $.widget( "mobile.filterable", {
this.document.find( selector );

this._on( search, {
keydown: "_onKeyDown",
keyup: "_onKeyUp",
change: "_onKeyUp",
input: "_onKeyUp"
Expand All @@ -170,6 +171,13 @@ $.widget( "mobile.filterable", {
this._search = search;
},

// Prevent form submission
_onKeyDown: function( event ) {
if ( event.keyCode === $.ui.keyCode.ENTER ) {
event.preventDefault();
}
},

_setOptions: function( options ) {
var refilter = !( ( options.filterReveal === undefined ) &&
( options.filterCallback === undefined ) &&
Expand Down

0 comments on commit 3d96d67

Please sign in to comment.