-
Notifications
You must be signed in to change notification settings - Fork 669
Caching with As.js
Jeffrey Warren edited this page Feb 2, 2019
·
4 revisions
Here is an example how I implement caching with this plugin. Hope its useful for folks here...
var cachequeryMentions = [], itemsMentions,
searchmentions = $('textarea').atwho("@", {
data: "/getmentions",
callbacks: {
remote_filter: function (params, url, render_view) {
var thisVal = params.q,
self = $(this);
if( !self.data('active') && thisVal.length >= 2 ){
self.data('active', true);
itemsMentions = cachequeryMentions[thisVal]
if(typeof itemsMentions == "object"){
render_view(itemsMentions);
}else
{
if (self.xhr) {
self.xhr.abort();
}
self.xhr = $.getJSON(url,{
term: thisVal
}, function(data) {
cachequeryMentions[thisVal] = data
render_view(data);
});
}
self.data('active', false);
}
}
}
});
});
Hope it helps!