Reputation: 1
i have the following script inside my asp.net MVC razor view:-
$("#Technology2_Tag").autocomplete({
minLength: 1, delay: 1000,
source: function (request, response) {
$.ajax({
url: "@Url.Content("~/Switch/AutoComplete2")",
dataType: "json",
data: {
term: request.term,
SearchBy: $("#ChoiceTag").prop("checked") ? $("#ChoiceTag").val() : $("#ChoiceName").val(),
},
success: function (data) {
response(data);
},
select: function (event, ui)
{
//get the value user selected
alert('t');
//your code populate data to dropdownlist...
}
});
},
});
The autocomplete is working well, but the select is not firing, for example after selecting an autocomplete item , no alert will be shown ? can anyone advice ? Thanks
Upvotes: 0
Views: 67
Reputation: 62488
It is placed inside ajax which is wrong,place it outside it like this:
$("#Technology2_Tag").autocomplete({
minLength: 1,
delay: 1000,
source: function (request, response) {
$.ajax({
url: "@Url.Content("~/Switch/AutoComplete2")",
dataType: "json",
data: {
term: request.term,
SearchBy: $("#ChoiceTag").prop("checked") ? $("#ChoiceTag").val() : $("#ChoiceName").val()
},
success: function (data) {
response(data);
}
}); // <----------ending of ajax
}, //<------- ending bracket of source function
select: function (event, ui)
{
//get the value user selected
alert('t');
//your code populate data to dropdownlist...
}
});
Upvotes: 1