Please take a look at the following autocomplete code.
$(document).ready(function(){
$("#the_input").autocomplete("/autocomplete.php", {
//some options
extraParams: {
base: $('.selected_button').prev('input').val() //***
},
formatItem: function(data, i, n, value) {
return value;
}
});
});
The “base” parameter is my problem (the part marked with the comment).
I have three buttons and three hidden input fields on the page.
Initially, when the page is loaded, I add the “selected_button” to one of the buttons.
I have confirmed that the jquery code after “base:” can be used to access this element.
When the user clicks on one of the other buttons, I remove the “selected_button” class from all the buttons and add it to the button that the user clicked.
I want to use this to change the base folder that is being used for the autocompletion lookup.
The problem is that the autocomplete always uses the path that was initially set, no matter what button I click.
So I think the autocomplete does not recognize the class changes that I make during runtime.
Have you tried wrapping the base parameter inside a function:
The docs seem to suggest this as a possibility.