I have several jquery ui objects and they all have a similar callback:
$(function() {
$("#my_list").autocomplete({
source: function(request, response) {
$.ajax({
type: "POST",
url: "api",
data: {
term: request.term,
},
success: response,
dataType: 'json',
minLength: 0,
});
},
minLength: 0,
select: function(event, ui) {
$('something').appendTo("#another_list");
}
}
});
});
If I could pass the "my_list" and "another_list" there as parameters, the code would be much cleaner. How can this be done?