On my site I'm currently using the jquery component "mentionsInput". It works fine, however it doesn't seem to work on newly ajax generated elements.
$(function () {
var data = [];
$(document).on('focus','.mention', function(){
var id = $(this).attr("data-entity");
$.ajax({
type: "GET",
url: host + '/users/mentions-list/' + id,
success: function(response) {
data = response;
}
});
});
$('.mention').mentionsInput({
onDataRequest:function (mode, query, callback) {
var requestData = _.filter(data, function(item){
return item.name.toLowerCase().indexOf(query.toLowerCase()) > -1;
});
callback.call(this, requestData);
}
});
});
The .on
focus function works just fine with newly generated elements, but the second function does not.
How could I resolve this issue?