From e3ca9a324f3c8f11620922bc621e44de963c4d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fracisco=20S=C3=A1ez?= Date: Mon, 27 Dec 2010 02:52:35 -0800 Subject: [PATCH] Autocompleter: Adding support for a "regexp" option. If it exists, Ajax requests are done only if the token matches with the "regexp" pattern. Useful when using text areas where not every token requires auto-completion. E.g. regexp: /(#|:)(\w)*/ would activate Ajax requests for tokens that starts with '#' or ':'. --- src/controls.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controls.js b/src/controls.js index cde682f..87ee12b 100644 --- a/src/controls.js +++ b/src/controls.js @@ -300,7 +300,8 @@ Autocompleter.Base = Class.create({ onObserverEvent: function() { this.changed = false; this.tokenBounds = null; - if(this.getToken().length>=this.options.minChars) { + this.options.regexp ? send=this.options.regexp.match(this.getToken()) : send=true; + if(send && this.getToken().length>=this.options.minChars) { this.getUpdatedChoices(); } else { this.active = false;