javascript - How to force the jQuery .change function to catch user selection from an autocomplete objects -
javascript - How to force the jQuery .change function to catch user selection from an autocomplete objects -
i have next text field auto finish feature:-
currently wrote folliwng grab within textbox :-
$("#textbox").change(function () { $.getjson("@url.content("~/switch/loadrelatedips")", { searchterm: $("#textbox").val(), searchby: $("#choicetag").prop("checked") ? $("#choicetag").val() : $("#choicename").val(), }, function (customerdata) { the problem facing $("#textbox").val() within getjson , grab value within text box , not user select auto finish result. illustration in above image $("#textbox").val() v10020 instead of total text should v100205 ? can advice how solve issue ? , not want utilize select within autocomplete , since in way have duplicate calls 1 .change , other autocomplete select function ?
the alter event fires when textbox loses focus, happen when user clicks autocomplete suggestion, before autocomplete javascript fills in finish value. right behaviour alter event.
seems want isn't execute code when device resource tag field changes, execute when right (complete) value has been entered. possible solution: in add-on handling select event of autocomplete, when performs search, check see if 1 result returned , matches user has entered, select automatically. in illustration above, if user types out finish string "v100205", autocomplete returns 1 result "v100205". cancel showing autocomplete , instead execute code.
javascript jquery
Comments
Post a Comment