I have a function that use jQuery autocomplete inside it:
var row_num = 5;
function addModule() {
// function addModule code
$('input[name=\'product\']').autocomplete({
delay: 0,
source: function(request, response) {
//function code
},
select: function(event, ui) {
//function code
$('input[name=\'module[' + row_num + '][featured]\']').attr('value',
data.join());
},
focus: function(event, ui) {
return false;
}
});
// function addModule code continues
});
Var row_num doesn’t work in body of autocomplete. I tried to declare it additionally in “select” and other different places but nothing. Looking through ui autocomplete documentation bring no results.
How to get autocomplete use my var ?
Change this line
To this
Maybe you are not expecting what you see?
This should be part of the closure. Have you tried it this way?