Permalink
Browse files

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

…ested tag by mouse
  • Loading branch information...
1 parent 1411cd6 commit 9d3813368df3ed7eb919fd9bf35c3c9c1cd153ab @amitamb amitamb committed Apr 7, 2012
Showing with 18 additions and 3 deletions.
  1. +18 −3 app/assets/javascripts/application.js
@@ -787,10 +787,25 @@ addthis.addEventListener('addthis.menu.share',shareEventHandler);
});
$e.find("li>input").focusout(function(e){
var $this = $(this);
- if ( $this.val() ) {
- var t= $this.val();
+ (function($this){
+ var old_val = $this.val();
+ setTimeout(function(){
+ if ( $this.val() && old_val == $this.val() ) {
+ var t= $this.val();
+ addTag(t);
+ $this.val("");
+ }
+ }, 110);
+ })($this);
+ });
+
+ var $e_input = $e.find("li>input");
+
+ $e.parents("form").submit(function(){
+ if ( $e_input.val() ) {
+ var t= $e_input.val();
addTag(t);
- $this.val("");
+ $e_input.val("");
}
});

0 comments on commit 9d38133

Please sign in to comment.