如何在jqueryui自动完成组合框中触发select事件处理程序?

时间:2022-05-12 19:42:58

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:

我有一个jqueryui自动完成组合框小部件,其中一旦用户选择组合框中的某些内容,组合框中的select事件处理程序进行ajax调用以在另一个div元素中呈现内容。例如:

[combo-box] > [div]

[组合框]> [div]

The div contains content in which the user can then click submit to go to a different page.

div包含用户可以在其中单击“提交”以转到其他页面的内容。

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.

我遇到了一个问题,如果用户点击后退按钮后在组合框中进行了选择,然后在div中单击以转到下一页,组合框将显示最后选择的值,但是div会在ajax请求(用动态内容填充div)之前显示最初在页面上呈现的值。因此,组合框中显示的值现在与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.

该问题的解决方案要求在首次加载页面时触发组合框中某个值的选择,以便运行jqueryui自动完成组合框代码中的select事件处理程序,这将重新加载div。

What is the best way to do so?

这样做的最佳方法是什么?

1 个解决方案

#1


1  

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)

您可以将选定的值存储到隐藏的输入中,并在页面加载时使用隐藏输入中的值绘制内容div(如果有)

#1


1  

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)

您可以将选定的值存储到隐藏的输入中,并在页面加载时使用隐藏输入中的值绘制内容div(如果有)