diff options
author | Bharat Mediratta <bharat@menalto.com> | 2013-02-17 00:23:50 -0500 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2013-02-17 00:23:50 -0500 |
commit | d632ef3e50252d388c272cacd29e8cc6e4949cec (patch) | |
tree | 2e8de0122a089d6205dd60e60e5fd2f6ded87138 /lib/gallery.common.js | |
parent | cc45e2e33b07cd27a87300f5d239394a14569308 (diff) |
Fix up autocomplete for admin_server_add - found and fixed some bugs
in gallery_autocomplete when "multiple" isn't set. Fixed some
harmless syntax issues that js2-mode helpfully pointed out.
Diffstat (limited to 'lib/gallery.common.js')
-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); |