I have 2 input box fields, one linked to an autocomplete and the other is hidden
I have an action on select that takes the id of the selected item into开发者_C百科 the hidden field.
code:
$('#id_emp_name').autocomplete({
source: '/mycompany/employees.json',
minLength: 1,
dataType: 'json',
max: 12,
select: function(event, ui) {
$('#id_emp_id').val(ui.item.id);
}
});
I want to change it so that whenever I delete contents (even a single character) on the autcomplete textbox it would set the hidden textbox's to ''
Would this work for you?
$('#id_emp_name').autocomplete({
source: '/mycompany/employees.json',
minLength: 1,
dataType: 'json',
max: 12,
select: function(event, ui) {
$('#id_emp_id').val(ui.item.id);
}
}).keyup(function(){
$('#id_emp_id').val('');
});
You may need to put some conditions on it of course.
精彩评论