如何触发 jqueryui 自动完成组合框中的选择事件处理程序?
我有一个 jqueryui 自动完成组合框小部件,其中一旦用户在组合框中选择了某些内容,组合框中的 select 事件处理程序就会进行 ajax 调用以在另一个 div 元素中呈现内容。 EG:
[组合框]> [div]
div 包含用户可以单击“提交”转到不同页面的内容。
我遇到一个问题,如果用户在组合框中进行选择后单击后退按钮,然后单击 div 进入下一页,组合框将显示最后选择的值,但 div 将显示在 ajax 请求(使用动态内容填充 div)之前最初在页面上呈现的值。因此,组合框中显示的值现在与 div 中显示的内容不一致。
此问题的解决方案要求我在首次加载页面时触发组合框中特定值的选择,以便运行 jqueryui 自动完成组合框代码中的 select 事件处理程序,这将重新加载 div。
最好的方法是什么?
I have a jqueryui autocomplete combo-box widget in which once the user selects something in the combobox, the select event handler within the combo-box makes an ajax call to render content in another div element. EG:
[combo-box] > [div]
The div contains content in which the user can then click submit to go to a different page.
I am running into a problem in which if the user clicks on the back button AFTER having made a selection within the combo-box and then clicking within the div to go to the next page, the combo-box will display the last selected value, but the div will display the value as it was originally rendered on the page, prior to the ajax request (which populated the div with dynamic content). As a result, the displayed value within the combo-box is now inconsistent with the displayed content in the div.
The solution to this problem requires that I trigger the select of a certain value within the combo-box when the page is first loaded, so that the select event handler within the jqueryui autocomplete combobox code is run, which will reload the div.
What is the best way to do so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将所选值存储到隐藏输入中,并在页面加载时使用隐藏输入中的值(如果有)绘制内容 div
You could store the selected value into a hidden input and on page load paint the content div with the value in the hidden input (if any)