From d8d8df71cf222cd96cf507e250035aafc88641af Mon Sep 17 00:00:00 2001 From: Jay Levitt Date: Fri, 27 May 2011 12:38:12 -0400 Subject: [PATCH] Teach tagsinput to use JQuery UI's built-in autocomplete --- jquery.tagsinput.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jquery.tagsinput.js b/jquery.tagsinput.js index 1c59bd3..f6cb3f9 100644 --- a/jquery.tagsinput.js +++ b/jquery.tagsinput.js @@ -109,7 +109,7 @@ } $.fn.tagsInput = function(options) { - var settings = jQuery.extend({interactive:true,defaultText:'add a tag',minChars:0,width:'300px',height:'100px','hide':true,'delimiter':',',autocomplete:{selectFirst:false},'unique':true,removeWithBackspace:true},options); + var settings = jQuery.extend({interactive:true,defaultText:'add a tag',minChars:0,width:'300px',height:'100px','hide':true,'delimiter':',',autocomplete:{},'unique':true,removeWithBackspace:true},options); this.each(function() { if (settings.hide) { @@ -168,7 +168,12 @@ }); if (settings.autocomplete_url != undefined) { - $(data.fake_input).autocomplete(settings.autocomplete_url,settings.autocomplete).bind('result',data,function(event,data,formatted) { + autocomplete_options = {source: settings.autocomplete_url} + for (attrname in settings.autocomplete) { + autocomplete_options[attrname] = settings.autocomplete[attrname]; + } + + $(data.fake_input).autocomplete(autocomplete_options).bind('result',data,function(event,data,formatted) { if (data) { $(event.data.real_input).addTag(formatted,{focus:true,unique:(settings.unique)});