php - at.js can't use remote filter no drop-down displayed
I've been trying to implement @mentions for my php application using the At.js library in version 1.5.1 from https://github.com/ichord/At.js
When i typing @ and something after, i see an ajax query in firebug, but i don't see the drop-down to select the differents names.
My javascript code used is the following :
$('#editor').atwho({
at: "@",
displayTpl:"<li data-value='${key}'>${username} <img src='${avatar}' height='20' width='20' /></li>",
callbacks: {
remoteFilter: function(query, callback) {
if(query.length > 0) {
$.ajax({
url: $( "#url_mentions" ).val(),
data: {
search : query
},
done: function(data) {
callback(data.users);
}
});
}
}
}
});
The json which is returned by calling the url directly in browser :
{"users":[{"key":"[mention userid=742]admin[\/mention]","userid":"1742","username":"admin","avatar":"<img class=\"kavatar\" src=\"http:\/\/jfconnectoquickstart\/media\/tr\/avatars\/resized\/size24\/cs\/s_nophoto.png\" width=\"24\" height=\"24\" alt=\"admin's Avatar\" \/>"},{"key":"[mention userid=743]jack[\/mention]","userid":"743","username":"jack","avatar":"<img class=\"kavatar\" src=\"http:\/\/jfconnectoquickstart\/media\/tr\/avatars\/resized\/size24\/cs\/s_nophoto.png\" width=\"24\" height=\"24\" alt=\"jack's Avatar\" \/>"}]}
The HTML part :
<div >
<label >Message</label>
<div >
<textarea name="message" id="editor" rows="12" tabindex="7"
required="required"></textarea>
</div>
</div>
Do-you have an idea to fix it ?
Thanks by advance
Answer
Solution:
Little late but might help others.
You must add "searchKey" parameters (see the first parameter)
});