diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-15 00:59:07 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-02-15 00:59:07 +0000 |
commit | 76e70b79acc60358a7225c0976fd6b7f2fe3c74f (patch) | |
tree | 06ecca63b1db52b83106a493dfb3eed0cc15ebb8 | |
parent | 25629c48781dd87b2594b03262a98abc4ee9a5eb (diff) | |
download | elgg-76e70b79acc60358a7225c0976fd6b7f2fe3c74f.tar.gz elgg-76e70b79acc60358a7225c0976fd6b7f2fe3c74f.tar.bz2 |
Refs #2102: addressing more userpicker/autocomplete bugs
git-svn-id: http://code.elgg.org/elgg/trunk@8246 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | js/lib/userpicker.js | 24 | ||||
-rw-r--r-- | views/default/input/autocomplete.php | 2 | ||||
-rw-r--r-- | views/default/input/userpicker.php | 2 |
3 files changed, 11 insertions, 17 deletions
diff --git a/js/lib/userpicker.js b/js/lib/userpicker.js index d978b9c82..2b3d78d6b 100644 --- a/js/lib/userpicker.js +++ b/js/lib/userpicker.js @@ -1,12 +1,16 @@ +elgg.provide('elgg.userpicker'); + elgg.userpicker.init = function() { // binding autocomplete. // doing this as an each so we can past this to functions. $('.elgg-input-user-picker').each(function() { - var params = elgg.userpicker.getSearchParams(this); + var _this = this; $(this).autocomplete({ source: function(request, response) { + var params = elgg.userpicker.getSearchParams(this); + elgg.get('pg/livesearch', { data: params, dataType: 'json', @@ -14,7 +18,7 @@ elgg.userpicker.init = function() { response(data); } }); - } + }, minLength: 2, select: elgg.userpicker.addUser }) @@ -22,16 +26,6 @@ elgg.userpicker.init = function() { //@todo This seems convoluted .data("autocomplete")._renderItem = elgg.userpicker.formatItem; }); - - - // changing friends vs all users. - $('.elgg-user-picker [name=match_on]').live('click', function() { - // update the extra params for the autocomplete. - var e = $(this).closest('.elgg-user-picker').find('.elgg-input-user-picker'); - var params = elgg.userpicker.getSearchParams(e); - e.setOptions({extraParams: params}); - e.flushCache(); - }); }; elgg.userpicker.formatItem = function(ul, item) { @@ -73,11 +67,11 @@ elgg.userpicker.addUser = function(event, ui) { $(this).val(''); } -} +}; -function elgg.userpicker.removeUser(link, guid) { +elgg.userpicker.removeUser = function(link, guid) { $(link).closest('.elgg-user-picker-entries > li').remove(); -} +}; elgg.userpicker.getSearchParams = function(e) { if ($(e).closest('.elgg-user-picker').find('[name=match_on]').attr('checked')) { diff --git a/views/default/input/autocomplete.php b/views/default/input/autocomplete.php index d0b12c31d..1093de2d3 100644 --- a/views/default/input/autocomplete.php +++ b/views/default/input/autocomplete.php @@ -29,7 +29,7 @@ $ac_url_params = http_build_query(array( unset($vars['match_on']); unset($vars['match_owner']); -elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'footer'); +elgg_register_js('js/lib/autocomplete.js', 'autocomplete', 'head'); ?> diff --git a/views/default/input/userpicker.php b/views/default/input/userpicker.php index 18c71a7f3..980af2684 100644 --- a/views/default/input/userpicker.php +++ b/views/default/input/userpicker.php @@ -18,7 +18,7 @@ * */ -elgg_register_js('js/lib/userpicker.js', 'userpicker', 'footer'); +elgg_register_js('js/lib/userpicker.js', 'userpicker', 'head'); function user_picker_add_user($user_id) { $user = get_entity($user_id); |