Skip to content
This repository
Browse code

Fixed the bug causing multiple tags getting added when selecting sugg…

…ested tag by mouse
  • Loading branch information...
commit 9d3813368df3ed7eb919fd9bf35c3c9c1cd153ab 1 parent 1411cd6
amitamb authored April 07, 2012

Showing 1 changed file with 18 additions and 3 deletions. Show diff stats Hide diff stats

  1. 21  app/assets/javascripts/application.js
21  app/assets/javascripts/application.js
@@ -787,10 +787,25 @@ addthis.addEventListener('addthis.menu.share',shareEventHandler);
787 787
 		});
788 788
 		$e.find("li>input").focusout(function(e){
789 789
 			var $this = $(this);
790  
-			if ( $this.val() ) {
791  
-				var t= $this.val();
  790
+			(function($this){
  791
+				var old_val = $this.val();
  792
+				setTimeout(function(){
  793
+					if ( $this.val() && old_val == $this.val() ) {
  794
+						var t= $this.val();
  795
+						addTag(t);
  796
+						$this.val("");
  797
+					}
  798
+				}, 110);
  799
+			})($this);
  800
+		});
  801
+		
  802
+		var $e_input = $e.find("li>input");
  803
+		
  804
+		$e.parents("form").submit(function(){
  805
+			if ( $e_input.val() ) {
  806
+				var t= $e_input.val();
792 807
 				addTag(t);
793  
-				$this.val("");
  808
+				$e_input.val("");
794 809
 			}
795 810
 		});
796 811
 

0 notes on commit 9d38133

Please sign in to comment.
Something went wrong with that request. Please try again.