can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r17385: LJSV-1130: Unexpected behaviour when cho...

Committer: dpetrov
LJSV-1130: Unexpected behaviour when choosing tag from drop-down list by Enter in Opera
U   trunk/htdocs/js/entry.js
Modified: trunk/htdocs/js/entry.js
===================================================================
--- trunk/htdocs/js/entry.js	2010-09-16 02:34:12 UTC (rev 17384)
+++ trunk/htdocs/js/entry.js	2010-09-16 06:00:02 UTC (rev 17385)
@@ -537,9 +537,28 @@
 
 function tagAutocomplete(node, tags)
 {
-	var searched;
+	var searched,
+		suppressKeypress = false;
 	
-	jQuery(node).autocomplete({
+	jQuery(node)
+	.keydown(function(event){ //fix form submit bug in opera
+		var self = jQuery(this).data('autocomplete');
+		var keyCode = jQuery.ui.keyCode;
+
+		if ( self.options.disabled  || !self.menu.element.is( ":visible" ) ) {
+			return;
+		}
+		if ( event.keyCode == keyCode.ENTER || event.keyCode == keyCode.NUMPAD_ENTER) {
+			suppressKeypress = true;
+		}
+	})
+	.keypress(function(event){
+		if ( suppressKeypress ) {
+			suppressKeypress = false;
+			event.preventDefault();
+		}
+	})
+	.autocomplete({
 		minLength: 1,
 		source: function(request, response) {
 			var val = this.element.context.value,

Tags: can3p, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments