Reputation: 15630
I am using jquery auto complete.Its all works fine.But the problem is that I am appending an option to add new record if the database does not having the queried value.So when I am selecting the add new [which is appeared as sames as the results came] the textbox value is changed to 0. I tried to make it "".But it is coming zero always[it is occuring when user tries to enter a value which is not in db,I am calling a function to add new record]. Any solution for this?
$("#<%=txtMfgr.ClientID %>").autocomplete({
source: "../AjaxGetData.ashx?man=1",
minLength: 0,
select: function(event, ui) {
$('#<%=hdfManId.ClientID %>').val(ui.item.value1);
}
});
I am adding an extra value1. The response is like this
[ { "id":"Wipro" , "label":"Wipro" , "value": "Wipro" , "value1": "6" }]
Hope some one can help me.Thanks in advance
Upvotes: 0
Views: 164
Reputation: 19164
Which element is $("#<%=txtMfgr.ClientID %>")
and which element is $('#<%=hdfManId.ClientID %>')
?
If you are updating the textfield on which the autocomplete plugin is instatiated, shouldn't the two selectors point to the same element? Meaning, if the asp.net expressions are evaluated it should be:
$("#mytextfield").autocomplete({
source: "../AjaxGetData.ashx?man=1",
minLength: 0,
select: function(event, ui) {
$('#mytextfield').val(ui.item.value1);
return false;
}
});
And yeah, the select callback should return false ;)
Upvotes: 1