对话框中的JQuery UI复选框值

时间:2022-02-10 20:36:11

I'm trying to build a Preferences dialog using JQuery UI and its dialog. I have several checkboxes the user can set. When the dialog opens, I set these checkboxes based on an internal Preferences list.

我正在尝试使用JQuery UI及其对话框构建一个Preferences对话框。我有几个用户可以设置的复选框。对话框打开后,我根据内部“首选项”列表设置这些复选框。

This works fine the first time I display the dialog, but on subsequent opens the dialog retains its last settings, even when Preferences haven't changed. That is, the visual appearance is retained, while the Preferences values haven't been changed.

这在我第一次显示对话框时工作正常,但在后续打开时,对话框会保留其最后的设置,即使首选项未更改也是如此。也就是说,保留了视觉外观,而没有更改“首选项”值。

If I revert to using plain old HTML checkboxes, they work correctly. It's only the JQuery UI checkboxes that stubbornly hold onto their last state.

如果我恢复使用普通的旧HTML复选框,它们可以正常工作。只有JQuery UI复选框固执地保持其最后状态。

This seems to be a pernicious problem, but there aren't any clear answers or examples on how to fix it. One approach - manually destroying, then re-writing the entire dialog on every call - seems utterly frustrating, and I'm hoping there's some better way of handling this problem while still being able to use JQuery UI widgets.

这似乎是一个有害的问题,但没有任何明确的答案或如何解决它的例子。一种方法 - 手动销毁,然后在每次调用时重写整个对话框 - 似乎非常令人沮丧,我希望有一些更好的方法来处理这个问题,同时仍然能够使用JQuery UI小部件。

1 个解决方案

#1


0  

Fixed this by explicitly calling button("refresh") on every checkbox element when I detect an update or when reloading. This apparently is required to sync the JQUI appearance with the underlying form element's state.

通过在检测到更新或重新加载时在每个复选框元素上显式调用按钮(“刷新”)来解决此问题。这显然需要将JQUI外观与底层表单元素的状态同步。

#1


0  

Fixed this by explicitly calling button("refresh") on every checkbox element when I detect an update or when reloading. This apparently is required to sync the JQUI appearance with the underlying form element's state.

通过在检测到更新或重新加载时在每个复选框元素上显式调用按钮(“刷新”)来解决此问题。这显然需要将JQUI外观与底层表单元素的状态同步。