Fixed 'Enter' submitting a form within WCF.Search.Base
authorAlexander Ebert <ebert@woltlab.com>
Tue, 30 Oct 2012 20:06:32 +0000 (21:06 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 30 Oct 2012 20:06:32 +0000 (21:06 +0100)
Closes #797

wcfsetup/install/files/js/WCF.js

index 7eb84e68de1724af22e04fe4f82caa2feb2cf610..312ecdd3d58d22d7f460008a5d7840495a3559a7 100755 (executable)
@@ -4467,7 +4467,7 @@ WCF.Search.Base = Class.extend({
                        return;
                }
                
-               this._searchInput.keyup($.proxy(this._keyUp, this)).wrap('<span class="dropdown" />');
+               this._searchInput.keydown($.proxy(this._keyDown, this)).keyup($.proxy(this._keyUp, this)).wrap('<span class="dropdown" />');
                this._list = $('<ul class="dropdownMenu" />').insertAfter(this._searchInput);
                this._commaSeperated = (commaSeperated) ? true : false;
                this._oldSearchString = [ ];
@@ -4484,6 +4484,17 @@ WCF.Search.Base = Class.extend({
                }
        },
        
+       /**
+        * Blocks execution of 'Enter' event.
+        * 
+        * @param       object          event
+        */
+       _keyDown: function(event) {
+               if (event.which === 13) {
+                       event.preventDefault();
+               }
+       },
+       
        /**
         * Performs a search upon key up.
         *