was dropping off the last key when inviting a user by email.

This commit is contained in:
Sam 2013-06-25 17:53:12 +10:00
parent 1106eb9902
commit 4c51f36db2
1 changed files with 20 additions and 11 deletions

View File

@ -203,18 +203,8 @@ $.fn.autocomplete = function(options) {
closeAutocomplete();
});
$(this).keypress(function(e) {
if(options.allowAny){
if(inputSelectedItems.length === 0) {
inputSelectedItems.push("");
}
inputSelectedItems.pop();
inputSelectedItems.push(me.val());
if (options.onChangeItems) {
options.onChangeItems(inputSelectedItems);
}
}
$(this).keypress(function(e) {
if (!options.key) return;
@ -232,6 +222,25 @@ $.fn.autocomplete = function(options) {
return $(this).keydown(function(e) {
var c, caretPosition, i, initial, next, nextIsGood, prev, prevIsGood, stopFound, term, total, userToComplete;
if(options.allowAny){
// saves us wiring up a change event as well, keypress is while its pressed
_.delay(function(){
if(inputSelectedItems.length === 0) {
inputSelectedItems.push("");
}
if(_.isString(inputSelectedItems[0])) {
inputSelectedItems.pop();
inputSelectedItems.push(me.val());
if (options.onChangeItems) {
options.onChangeItems(inputSelectedItems);
}
}
},50);
}
if (!options.key) {
completeStart = 0;
}