I have this code:
$("#xyz").unautocomplete().autocomplete(dataVar, {
minChars: 0,
width: 400,
matchContains: true,
highlightItem: true,
formatItem: formatItem,
formatResult: formatResult
})
.result(findValueCallback).next().click(function() {
$(this).prev().search();
});
I call this code many times and the first call works correctly, but after
he calls findValueCallback
many times, not once more.
The unautocomplete
don't clear .result
What I have to do for call findValueCallback
once?
Sample Code:
var niveis01 = [];
var niveis02 = [];
var niveis03 = [];
$(document).ready(function(){
carregaDadosNivel1();
});
function carregaDadosNivel1() {
$.ajax({
url: "http://.....",
cache: true,
type: "POST",
dataType:"json",
success: function(data){
...
niveis01 = data;
habilitaComboNivel1();
...
},
error: function(xhr, ajaxOptions, thrownError){
...
}
});
}
function habilitaComboNivel1() {
function findValueCallback1(event, data01, formatted) {
...
carregaDadosNivel2();
...
}
$("#nivel01").unautocomplete().autocomplete(niveis01, {
minChars: 0,
width: 400,
matchContains: true,
highlightItem: true,
formatItem: formatItem,
formatResult: formatResult
}).result(findValueCallback1).next().click(function() {
$(this).prev().search();
});
}
function carregaDadosNivel2() {
$.ajax({
url: "http://.....",
cache: true,
type: "POST",
dataType:"json",
success: function(data){
...
niveis02 = data;
habilitaComboNivel2();
...
},
error: function(xhr, ajaxOptions, thrownError){
...
}
});
}
function habilitaComboNivel2() {
function findValueCallback2(event, data02, formatted) {
...
carregaDadosNivel3();
...
}
$("#nivel02").unautocomplete().autocomplete(niveis02, {
minChars: 0,
width: 400,
matchContains: true,
highlightItem: true,
formatItem: formatItem,
formatResult: formatResult
}).result(findValueCallback2).next().click(function() {
$(this).prev().search();
});
}
function carregaDadosNivel3() {
$.ajax({
url: ""http://.....",
cache: true,
type: "POST",
dataType:"json",
success: function(data){
...
niveis03 = data;
habilitaComboNivel3();
...
},
error: function(xhr, ajaxOptions, thrownError){
...
}
});
}
function habilitaComboNivel3() {
function findValueCallback3(event, data03, formatted) {
...
}
$("#nivel03").unautocomplete().autocomplete(niveis03, {
minChars: 0,
width: 400,
matchContains: true,
highlightItem: true,
formatItem: formatItem,
formatResult: formatResult
}).result(findValueCallback3).next().click(function() {
$(this).prev().search();
});
}