Permalink
Browse files

better fix for clicking on autocomplete list that causes premature se…

…lection
  • Loading branch information...
DimitarChristoff committed Dec 28, 2011
1 parent 3f2402f commit 1146636ed6eb0c54f6fadeae2aead1bb47fd5f68
Showing with 16 additions and 7 deletions.
  1. +16 −7 Source/js/mooTagify.js
View
@@ -349,9 +349,6 @@ var mooTagify = this.mooTagify = new Class({
var self = this;
if (this.options.autoSuggest && this.request) {
this.autoSuggester = new autoSuggest(this.element.getElement("input"), this.request, {
- onSelect: function() {
- self.extractTags();
- },
onDelete: function() {
var last = self.element.getElements(self.options.tagEls).getLast();
if (last)
@@ -362,29 +359,41 @@ var mooTagify = this.mooTagify = new Class({
});
}
+ this.clicked = false;
this.element.addEvents({
"blur:relay(input)": this.extractTags.bind(this),
"click:relay(span.tagClose)": this.removeTag.bind(this),
"keydown:relay(input)": function(e, el) {
if (e.key == "enter") {
- e.target.blur();
- }
+ this.extractTags();
+ }
+ }.bind(this),
+ "mousedown": function() {
+ this.clicked = true;
+ }.bind(this),
+ "mouseup": function() {
+ this.clicked = false;
}.bind(this)
});
this.fireEvent("ready");
},
extractTags: function() {
- (function() {
+ this.timer = (function() {
+ if (this.clicked)
+ return;
+
+ clearInterval(this.timer);
var newTags = this.listTags.get("value").clean().stripScripts().toLowerCase();
if (newTags.length) {
this.processTags(newTags);
if (this.options.persist)
this.listTags.focus();
}
- }).delay(300, this);
+
+ }).periodical(200, this);
},
processTags: function(tags) {

0 comments on commit 1146636

Please sign in to comment.