检查是否单选按钮在Firefox检查 [英] Checking if radio buttons are checked in Firefox

查看:183
本文介绍了检查是否单选按钮在Firefox检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站,我在我的ASP.NET MVC创建两个复选框查看像这样:

  Html.RadioButton(检查,真,真==(串)计算机[someKey],新{ID =CHECK1});
(检查,假,假==(串)计算机[someKey],新{ID =CHECK2})Html.RadioButton;

我肯定计算机[someKey]中有值true。

在我的JS初始化函数,我进行以下检查:

 警报($('#CHECK1')是(':检查')++ $('#CHECK2')是(。':检查'));

在火狐(只有Firefox浏览器),我的警告对话框将显示以下内容(它的工作原理如预期其他浏览器):

 初始页面加载:真的假的
通过按Ctrl + R标准刷新:虚假
通过刷新按Ctrl + Shift + R键跳过缓存:真的假的

我已经试过看着复选框值,包括 $('#CHECK1')。ATTR('检查')无功而返许多不同的方法。如果我检查了Firebug的HTML,我可以看到第一个单选按钮=选中属性检查它。

为什么复选框值FF改变当我刷新了,我怎么能缓解呢?由于这似乎是一个只有FF-的bug,我怎样才能改变我的code,使其工作?

这太问题好像问类似的东西,但没有的提出的解决方案似乎在此情况下工作。

修改:我还要指出作为托运要么,尽管HTML是什么,当单选按钮在FF刷新后呈现的,它实际上并不存在的显示的告诉我。

EDIT2 :添加原始HTML作为每个请求

 <输入ID =CHECK1类型=电台值=真NAME =检查检查=选中/>
<输入ID =CHECK2类型=电台值=FALSENAME =检查/>


解决方案

看来,问题不在于的检查的单选按钮是否被选中,但更多的,他们的按钮实际上是未选中即使HTML code,否则说。

我已经张贴到这个<一个一个的后续问题href=\"http://stackoverflow.com/questions/1574988/radio-buttons-being-reset-in-ff-on-cache-refresh\">here作为附录这个话题。

修改此页面有问题的一个很好的说明,你可以采取的解决解决方案。

On my site, I have two checkboxes created in my ASP.NET MVC view like so:

Html.RadioButton("check", "true", "true" == (string) ViewData["someKey"], new { id = "check1"});
Html.RadioButton("check", "false", "false" == (string) ViewData["someKey"], new { id = "check2"});

I am positive that ViewData["someKey"] has the value "true" in it.

In my JS init function, I perform the following check:

alert($('#check1').is(':checked') + " " + $('#check2').is(':checked'));

In Firefox (and only Firefox), my alert dialog will show the following (it works as expected in every other browser):

Initial page load: true false
Normal refresh via Ctrl + R: false false
Refresh skipping cache via Ctrl + Shift + R: true false

I have tried many different methods of looking at the checkbox value, including $('#check1').attr('checked') without success. If I examine the HTML in Firebug, I can see that the first radio button has the property checked="checked" in it.

Why is the checkbox value changing in FF when I refresh, and how can I mitigate this? Since this seems to be a FF-only bug, how can I change my code to make it work?

This SO question seemed to ask something similar, but none of the proposed solutions seem to work in this case.

Edit: I should also point out that when the radio button is rendered after the refresh in FF, it's not actually being displayed as checked either, despite what the HTML is telling me.

Edit2: Adding raw HTML as per request

<input id="check1" type="radio" value="True" name="check" checked="checked"/>
<input id="check2" type="radio" value="False" name="check"/>

解决方案

It seems that the problem isn't with checking whether or not the radio buttons are checked, but more that they buttons are actually unchecked even though the HTML code says otherwise.

I've posted a followup question to this one here as an addendum to this topic.

EDIT: This page has a good description of the problem and the solutions you can take to solve it.

这篇关于检查是否单选按钮在Firefox检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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