I’m trying to implement an instant search mechanism using the Yii framework.
What I want to do is catch key events and update the search term every time. It is working but problems will occur depending on user’s typing speed. What I need is a way to abort ongoing update calls, so that only the last search and grid view update call will matter.
Here’s the code
var runningQSRequest = false;
var qsrequest;
function activate_quicksearch() {
if (runningQSRequest){
qsrequest.abort(); //this doesn't work in Yii framework
}
runningQSRequest = true;
qsrequest = $.fn.yiiGridView.update('products-grid', {
data: $.cookie('filter_query') + '&Products[name]=' + escape($("#quick-search").val())
});
}
Instead of aborting the request, try throttling