Skip to content
Snippets Groups Projects
Commit d87ba046 authored by Aaron Ogle's avatar Aaron Ogle
Browse files

Modified find for autocomplete to show usernames that begin with what you type

parent 067bbd57
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ Template.messagePopupConfig.helpers ...@@ -11,7 +11,7 @@ Template.messagePopupConfig.helpers
getInput: self.getInput getInput: self.getInput
textFilterDelay: 200 textFilterDelay: 200
getFilter: (collection, filter) -> getFilter: (collection, filter) ->
exp = new RegExp(filter, 'i') exp = new RegExp("^#{filter}", 'i')
Meteor.subscribe 'onlineUsers', filter Meteor.subscribe 'onlineUsers', filter
items = onlineUsers.find({$or: [{name: exp}, {username: exp}]}, {limit: 5}).fetch() items = onlineUsers.find({$or: [{name: exp}, {username: exp}]}, {limit: 5}).fetch()
...@@ -25,7 +25,6 @@ Template.messagePopupConfig.helpers ...@@ -25,7 +25,6 @@ Template.messagePopupConfig.helpers
exp = new RegExp("(^|\\s)#{filter}", 'i') exp = new RegExp("(^|\\s)#{filter}", 'i')
if exp.test(all.username) or exp.test(all.compatibility) if exp.test(all.username) or exp.test(all.compatibility)
items.unshift all items.unshift all
return items return items
getValue: (_id, collection, firstPartValue) -> getValue: (_id, collection, firstPartValue) ->
...@@ -121,4 +120,4 @@ Template.messagePopupConfig.helpers ...@@ -121,4 +120,4 @@ Template.messagePopupConfig.helpers
return results return results
return config return config
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment