Permalink
Browse files

Fix issue #10 (mustMatch and minChars)

  • Loading branch information...
1 parent a744ce2 commit 7d8f6324c655145f4e6874d2baf564f0420c9a72 Dylan Verheul committed Feb 8, 2012
Showing with 15 additions and 17 deletions.
  1. +7 −0 Makefile
  2. +2 −0 demo/index.html
  3. +1 −1 package.json
  4. +4 −5 src/jquery.autocomplete.js
  5. +1 −11 src/jquery.autocomplete.min.js
View
@@ -0,0 +1,7 @@
+#
+# BUILD minified JavaScript
+# requires uglifyjs
+#
+
+autocomplete:
+ uglifyjs -nc ./src/jquery.autocomplete.js > ./src/jquery.autocomplete.min.js
View
@@ -12,6 +12,8 @@
$(function() {
$("#ac1").autocomplete('search.php', {
+ minChars: 3,
+ mustMatch: true,
selectFirst: true
});
View
@@ -1,6 +1,6 @@
{
"name": "autocomplete",
- "version": "3.0.0",
+ "version": "2.0.0",
"title": "jQuery Autocomplete",
"author": {
"name": "Dylan Verheul",
@@ -494,11 +494,10 @@
$.Autocompleter.prototype.activateNow = function() {
var value = this.beforeUseConverter(this.dom.$elem.val());
if (value !== this.lastProcessedValue_ && value !== this.lastSelectedValue_) {
+ this.active_ = true;
this.lastProcessedValue_ = value;
if (value.length >= this.options.minChars) {
this.fetchData(value);
- } else {
- this.finish();
}
}
};
@@ -784,7 +783,6 @@
if (this.autoFill(first, filter) || this.options.selectFirst || (this.options.selectOnly && numResults === 1)) {
this.focusItem($first);
}
- this.active_ = true;
};
$.Autocompleter.prototype.showResult = function(value, data) {
@@ -896,11 +894,12 @@
this.callHook('onNoMatch');
}
this.dom.$results.hide();
- this.lastKeyPressed_ = null;
- this.lastProcessedValue_ = null;
if (this.active_) {
this.callHook('onFinish');
}
+ this.lastKeyPressed_ = null;
+ this.lastProcessedValue_ = null;
+ this.lastSelectedValue_ = null;
this.active_ = false;
};
Oops, something went wrong.

0 comments on commit 7d8f632

Please sign in to comment.