javascript - jQuery autocomplete not firing for one of three on a page -
i have 3 autocomplete textboxes on page , cannot figure out why 1 of them not source data, function never fired other 2 are.
here js:
$("#txtuserid").autocomplete({ delay: 0, minlength: 0, autofocus: true, source: function (request, response) { $.ajax({ type: 'get', data: { 'data': request.term }, datatype: 'json', url: '@url.action("getallusers")', success: function (data) { response($.map(data, function (obj) { return { value: obj.value, label: obj.text } })); } }); }, select: function (event, ui) { neworold = "old"; $.ajax({ type: 'get', datatype: 'json', url: '@url.action("getuser")', data: { userid: ui.item.value }, success: function (data) { if (data.userid == null) { $("#lblerror").text("user not found"); $("#messagedialog").dialog({ title: "user maintenance" }); $("#messagedialog").dialog("open"); } else { $("#txtusername").val(data.username); $("#txtuserrole").val(data.userrole); $("#chkuseradmin").prop("checked", data.admin); $("#chkusertrans").prop("checked", data.trans); $("#chkuserreports").prop("checked", data.reports); $("#txtuserid").val(data.userid); $("#txtfirstname").val(data.firstname); $("#txtlastname").val(data.lastname); $("#txtinventoryrole").val(data.inventoryrole); $("#txtdept").val(data.department); $("#lblroledesc").text(data.userroledescription); $("#lblinvroledesc").text(data.roledescription); } }, error: function (xhr) { var err = xhr.responsetext; alert('error'); } }); } }).focus(function () { $("#txtuserid").autocomplete('search', $("#txtuserid").val()); })
html:
<td> <b style="color:red">*</b>find user id or enter new:<br /> @html.validationmessagefor(x=>x.userid) </td> <td> @html.textboxforwithtitle(x=>x.userid, new { @id = "txtuserid", style = "text-transform:uppercase", @class = "usermodel, textboxsize"}) </td>
no matter move box never kicks off source function. action:
[httpget] public actionresult getallusers(string data) { list<textvaluepair> items = getallusers(); var result1 = items.where(item => item.toupper().contains(data.toupper())).tolist(); return json(result1, jsonrequestbehavior.allowget); }
any ideas? puzzling thing working last week , not now. unfortunately not have code repository cannot earlier version.
Comments
Post a Comment