You can use the callback remote_filter:
$('#textarea').atwho({
at: "@",
show_the_at: true,
callbacks: {
remote_filter: function(query, callback) {
if (query.length < 1) {
return false
}
$.getJSON("/users.json", {q: query}, function(data) {
callback(data.usernames)
});
}
}
})
> "q" ( ) /users.json. :
def index
respond_to do |format|
format.json{ render :json => User.where('username like ?', "#{q}%").pluck(:username).compact}
end
end
> :
https://github.com/ichord/At.js/wiki/How-to-use-remote_filter