diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gallery.common.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js index 95988573..548aa29a 100644 --- a/lib/gallery.common.js +++ b/lib/gallery.common.js @@ -229,11 +229,11 @@ source: function(request, response) { var split = function(val) { return val.split(/,\s*/); - } + }; var extract_last = function(term) { return split(term).pop(); - } + }; var ajax_options = { dataType: "json", @@ -241,15 +241,17 @@ success: function(data) { response(data); }, + data: { + term: request.term + }, + dataFilter: function(data, dataType) { + // Drop the <meta> tag + return data.substring(data.indexOf("\n") + 1); + } }; - if (options.multiple) { - + if ("multiple" in options) { $.extend(ajax_options, { - dataFilter: function(data, dataType) { - // Drop the <meta> tag - return data.substring(data.indexOf("\n") + 1); - }, data: { term: extract_last(request.term) } @@ -258,12 +260,12 @@ $.ajax(ajax_options, response); } - } + }; - if (options.multiple) { + if ("multiple" in options) { var split = function(val) { return val.split(/,\s*/); - } + }; $.extend(autocomplete_options, { focus: function(event, ui) { var terms = split(this.value); @@ -280,7 +282,7 @@ this.value = terms.join(", "); return false; } - }) + }); } $(this).autocomplete(autocomplete_options); |