jQuery UI MultiSelect Widget选择保留在IE中,但未保留在Chrome中 [英] jQuery UI MultiSelect Widget selection retained in IE but not Chrome

查看:91
本文介绍了jQuery UI MultiSelect Widget选择保留在IE中,但未保留在Chrome中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery MultiSelect Widget .使用IE时,如果我从基本下拉列表中选择3个选项,浏览到另一页,然后按浏览器的后退按钮,则这些值将保留在下拉列表中.如果刷新页面,则值仍会保留.强制刷新会清除这些值.

在Chrome中,如果我做同样的事情,值将不会保留.

对于我的网站(不幸的是,该网站现在还不能通过Internet访问),在IE8中,该复选框的选中状态似乎在视觉上得以保留,但是该复选框的状态未被选中.

我尝试调用'uncheckAll'方法,并且复选框仍处于选中状态.我在代码中放了一个警报,以显示所选选项的数量,即使选中了复选框,该值也为零.

IE如何保留多选列表的状态,并且可以防止这种情况发生?

解决方案

调用multiselect插件的unchekAll()方法似乎是最简单的方法.由于我看不到您的代码,也许您没有以正确的方式调用它:

$("select").multiselect("uncheckAll");

但是现在,该方法在哪里调用?

为了实现跨浏览器的一致性,我认为正确的方法是使用onbeforeunload处理程序,据我所知,该处理程序将在所有浏览器中触发.因此,此代码段在所有情况下均适用:

window.onbeforeunload = function(){$("select").multiselect("uncheckAll")};

让我知道这是否可以解决您的问题吗?

I'm using the jQuery MultiSelect Widget. When using IE, if I select 3 options from the basic dropdown, browse to another page and then press the browser back button, the values are retained in the dropdown. If I refresh the page, the values are still retained. A force refresh clears the values.

In Chrome if I do the same thing the values are not retained.

With my website (which is unfortunately not yet accessible via the Internet), in IE8, the checked state of the checkboxes seems to be retained visually but the state of the checkbox is unchecked.

I have tried calling the 'uncheckAll' method and the checkboxes are still checked. I put an alert in my code to display the number of selected options and the value is zero even though checkboxes are selected.

How is the state of the multiselect list being retained by IE and can it be prevented?

解决方案

Calling unchekAll() method of multiselect plugin seems to be the easiest way. As i cannot see your code, maybe you are not calling it the right way:

$("select").multiselect("uncheckAll");

But now, where to call this method?

For cross browser consistency, i think the right way is to use the onbeforeunload handler, which is fired in all browsers as i'm aware of. So, this snippet should work in all case:

window.onbeforeunload = function(){$("select").multiselect("uncheckAll")};

Let me know if this fix your issue?

这篇关于jQuery UI MultiSelect Widget选择保留在IE中,但未保留在Chrome中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆