gpt4 book ai didi

jquery - 如何动态更改选择的选择框?

转载 作者:行者123 更新时间:2023-12-03 22:35:05 28 4
gpt4 key购买 nike

我正在使用 Google Maps API 创建可选择社区的列表,并使用 Chosen 使其看起来更漂亮。我遇到的问题是 Maps API 不会立即获取数据 - 它通过回调函数来获取数据,这意味着 Chosen 在添加选项之前应用自身,因此选项不会运行通过选择(导致他们根本没有出现)。

我认为理论上,如果我可以在应用 Chosen 之前获取 select 中的元素,那么它应该可以工作,但我不确定如何准确地做到这一点。有什么想法吗?

最佳答案

尝试过文档建议的内容吗?

Updating Chosen Dynamically

If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "liszt:updated" event on the field. Chosen will re-build itself based on the updated content.

jQuery Version: $("#form_field").trigger("liszt:updated");
Prototype Version: Event.fire($("form_field"), "liszt:updated");

或者,如果使用更新版本:

jQuery Version: $("#form_field").trigger("chosen:updated");
Prototype Version: Event.fire($("form_field"), "chosen:updated");

http://harvesthq.github.com/chosen/

关于jquery - 如何动态更改选择的选择框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8336112/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com