aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/lib/autocomplete.js31
1 files changed, 7 insertions, 24 deletions
diff --git a/js/lib/autocomplete.js b/js/lib/autocomplete.js
index 748070eaa..917326d4f 100644
--- a/js/lib/autocomplete.js
+++ b/js/lib/autocomplete.js
@@ -5,35 +5,18 @@ elgg.provide('elgg.autocomplete');
elgg.autocomplete.init = function() {
$('.elgg-input-autocomplete').autocomplete({
- source: function( request, response ) {
- $.ajax({
- url: elgg.autocomplete.url, //gets set by input/autocomplete
- dataType: "json",
- data: {
- q: request.term
- },
- success: function( data ) {
- response( $.map( data, function( item ) {
- item.value = item.name;
- return item;
- }));
- }
- })
- },
+ source: elgg.autocomplete.url, //gets set by input/autocomplete
minLength: 1,
select: function(event, ui) {
var item = ui.item;
- item.value = item.name;
-
- if($(this).next().attr('type') == "hidden"){
- var hidden = $(this).next();
- } else {
- var hidden = $(this).after('<input type="hidden" name="'+this.name+'[]" />').next();
- }
+ $(this).val(item.name);
+
+ var hidden = $(this).next();
hidden.val(item.guid);
}
})
+ //@todo This seems convoluted
.data("autocomplete")._renderItem = function(ul, item) {
switch (item.type) {
case 'user':
@@ -48,9 +31,9 @@ elgg.autocomplete.init = function() {
return $("<li/>")
.data("item.autocomplete", item)
- .append('<a>'+r+'</a>')
+ .append(r)
.appendTo(ul);
};
};
-elgg.register_hook_handler('init', 'system', elgg.autocomplete.init);
+elgg.register_hook_handler('init', 'system', elgg.autocomplete.init); \ No newline at end of file