2011-02-10 116 views
0
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); 
     } 
    } 
} 

在運行時我已加載集合並將集合推入jquery autocomplet。但緩存不是空的。請告訴我如何清除緩存...........刪除jquery自動完成緩存

回答

0

試試這個:

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

設置緩存長度爲1:

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

簡單的解決方案:

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

不會`$(「#element」)。unautocomplete()。autocomplete(newData)`也可以嗎? – kay 2012-07-13 13:20:49

1

試試這個:

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