A small problem with Jquery autocomplete
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
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 ;)
精彩评论