I have a strange problem with a jquery autocomplete widget. First I have a 'select' HTML element which displays all the projects. I also have an input element in which I can search for questionnaires which correspond to the selected project.
So I have this code : http://jsfiddle.net/AMkKX/1/
Everything works great. But my problem is when I refresh the page (with F5, not Ctrl+F5) : the previous choice of the select box is always selected so I want to change the source of the autocomplete widget (the code I show you should do that)
But the source doesn't change unless I put an alert before $('#search-questionnaire').autocomplete('option', 'source', data);
:
$('#search-project').change(function () {
var data;
var val = $(this).val();
alert('val : ' + val);
if (val != '')
data = questionnairesData[val];
else
data = allQuestionnairesData;
$('#search-questionnaire').autocomplete('option', 'source', data);
});
So I don't understand. Is it a bug ?
EDIT : I can't show you the 'F5 refresh' thing with jsfiddle. If you want to test it you have to copy the code and use it in your navigator.