Skip to content

Commit

Permalink
feat: allow autocomplete to pass optional params to user.search
Browse files Browse the repository at this point in the history
  • Loading branch information
psychobunny committed Sep 25, 2020
1 parent f8032cd commit 611f3c6
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions public/src/modules/autocomplete.js
Expand Up @@ -5,7 +5,12 @@
define('autocomplete', function () {
var module = {};

module.user = function (input, onselect) {
module.user = function (input, params, onselect) {
if (typeof params === 'function') {
onselect = params;
params = {};
}

app.loadJQueryUI(function () {
input.autocomplete({
delay: 200,
Expand All @@ -16,10 +21,10 @@ define('autocomplete', function () {
handleOnSelect(input, onselect, event, ui);
},
source: function (request, response) {
socket.emit('user.search', {
query: request.term,
paginate: false,
}, function (err, result) {
params.query = params.query || request.term;
params.paginate = params.paginate || false;

socket.emit('user.search', params, function (err, result) {
if (err) {
return app.alertError(err.message);
}
Expand Down Expand Up @@ -114,7 +119,7 @@ define('autocomplete', function () {
};

function handleOnSelect(input, onselect, event, ui) {
onselect = onselect || function () {};
onselect = onselect || function () { };
var e = jQuery.Event('keypress');
e.which = 13;
e.keyCode = 13;
Expand Down

0 comments on commit 611f3c6

Please sign in to comment.