jQuery 自动建议仅适用于两个字段之一
我想要两个带有 jquery autosuggest 插件的文本字段。
它在第一个字段中工作得很好:
致电:
$("#cphContent_txtCity").autocomplete({ source: "ClassLibrary/Cities.aspx", minLength: 2, select: function (event, ui) { } });
回复:["Munchberg","Muncheberg","Munchen","Munchenbernsdorf","Munchendorf","Munchhouse","Munchsmunster"]
之后我添加了第二个字段(使用不同的 sql 语句复制):
呼叫:
$("#cphContent_txtExpertise").autocomplete({ source: "ClassLibrary/Expertises.aspx", minLength: 2, select: function (event, ui) { } });
回复:
["Acupressure","Acupuncture"]
当我检查 firebug 时,我可以看到两个字段都会触发呼叫,但只有第一个字段(城市)会给出建议。
我真的看不出有什么问题。也许有人可以指出我正确的方向?
I would like to have two textfields with the jquery autosuggest plugin.
It is working just fine with the first field:
Call:
$("#cphContent_txtCity").autocomplete({ source: "ClassLibrary/Cities.aspx", minLength: 2, select: function (event, ui) { } });
Reply:["Munchberg","Muncheberg","Munchen","Munchenbernsdorf","Munchendorf","Munchhouse","Munchsmunster"]
After that I've added a second field (copy with different sql statement):
Call:
$("#cphContent_txtExpertise").autocomplete({ source: "ClassLibrary/Expertises.aspx", minLength: 2, select: function (event, ui) { } });
Reply:
["Acupressure","Acupuncture"]
When I check with firebug I can see that both fields trigger the call, but only the first field (cities) will give the suggestions.
I really can't see anything wrong with it. Maybe someone could point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保第二个自动完成返回“值”或“标签”字段,以便 jquery 知道要显示什么。从文档中:
Make sure the second autocomplete is returning a 'value' or 'label' field so jquery knows what to show. From the documentation: