Shohel
Shohel

Reputation: 3934

Remove Jquery AutoComplete Cache

var CollectionForAutoComplete = new Array();
function AutoCompleteTextBox() {

    var data = CollectionForAutoComplete;
    //var ac = $("#setcommonelement_ElementName").autocomplete(data);
    //ac.disable();
    // ac.setOptions({ noCache: true });

    $("#setcommonelement_ElementName").autocomplete(data, {
        minChars: 0,
        width: 262,
        matchContains: "word",
        scrollHeight: 220,    
        cacheLength: 0

    });
}

function generateStringForAutoComplete(CommonElementCollectionlist) {
    if (CommonElementCollectionlist.length > 0) {
        CollectionForAutoComplete.length = 0;
        for (i = 0; i < CommonElementCollectionlist.length; i++) {
            CollectionForAutoComplete.push(CommonElementCollectionlist[i].ElementName);
        }
    }
}

in run time i have loaded the collection and the push the collection into jquery autocomplet. but cache is not to be empty. please tell me how can i clear cache...........

Upvotes: 0

Views: 9041

Answers (4)

Pradeep Nayak
Pradeep Nayak

Reputation: 675

Try this:

$("#setcommonelement_ElementName").result(function()
{
    $("#setcommonelement_ElementName").flushCache();
});

Upvotes: 0

Cbeltran
Cbeltran

Reputation: 11

Try this:

$('#elementoautocomplete').bind("change mouseover click keyup", function() {
    $("#elementoautocomplete").flushCache();
});
$('#elementoautocomplete').autocomplete('archive.php', {  });
// write this out 

Upvotes: 1

Zorro
Zorro

Reputation: 175

Simple Solution :

$("#element").unautocomplete();
$("#element").autocomplete(newData);

Upvotes: 0

gath
gath

Reputation: 25472

Set the cache length to 1:

$"#your_selector").autocomplete('/url/',{
  ...,
  cacheLength: 1
});

Upvotes: 0

Related Questions