Skip to main content

Bug Tracker

Side navigation

#10461 closed bug (worksforme)

Opened October 09, 2011 04:43PM UTC

Closed October 09, 2011 09:07PM UTC

Last modified August 20, 2012 01:50PM UTC

selector :checked sometimes returns object with checked attribute false (Opera only)

Reported by: sea128@post.cz Owned by:
Priority: low Milestone: None
Component: selector Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:
Description

Tested on Opera 11.51 Windows 7. This works at IE 9 and Firefox 6.0.3 and Firefox 7.0.1 without problems.

$("input[name='bar']:checked")
sometimes returns object with checked attribute set to false.

Clicking on disallow and allow radios sometimes did not change disable property.

How to reproduce bug:

clicking on disallow and allow radios with rate 1 click per second. If disabling and enabling checkbox working then click on "Not interesting" radio (unchecked) and then continue clicking on disallow and allow radios.

How to not reproduce bug:

click very slow rate (about 1 click per 10 seconds).

I do not know if this selector is invalid (it works in IE and Firefox) but I know how workaround this problem. Instead of

$("input[name='bar']:checked")
use
$("input[name='bar']").filter(":checked")

Example code:

#!xml
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title></title>
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
  <script type='text/javascript'>
  //<![CDATA[ 
  $(document).ready(function() {
    function update() {
		var element = $("input[name='bar']:checked");	//BUGGY
		//var element = $("input[name='bar']").filter(":checked");//WORKING
		if (element.length==1&&!element[0].checked) {
			alert("Error");
		}
        var value = element.val();
        if (value == "disallow") {
            $("#some_checkbox").prop({
                disabled: true
            });
        } else {
            $("#some_checkbox").prop({
                disabled: false
            });
        }
    }
    update();
    $("input[type='radio']").change(function() {
        update();
    });

});
  //]]> 
  </script>
  
</head>
<body>
  <form action="" method="post">
    <div>
        <input type="radio" name="foo" value="foo1" id="foo1" checked="checked"><label for="foo1">Not interesting 1</label><br> 
        <input type="radio" name="foo" value="foo2" id="foo2"><label for="foo2">Not interesting 2</label><br> 
        <input type="radio" name="bar" value="disallow" id="disallow" checked="checked"><label for="disallow">Disallow checkbox</label><br>
        <input type="radio" name="bar" value="allow" id="allow"><label for="allow">Allow checkbox</label><br> 
        <input type="checkbox" id="some_checkbox" name="some_checkbox"><label for="some_checkbox">some checkbox</label>
    </div>
</form>
</body>
</html>
Attachments (0)
Change History (2)

Changed October 09, 2011 09:07PM UTC by timmywil comment:1

component: unfiledselector
priority: undecidedlow
resolution: → worksforme
status: newclosed

Works for me in Opera 11.51.

http://jsfiddle.net/timmywil/MWmBR/1/

Changed August 20, 2012 01:50PM UTC by lexx918@mail.ru comment:2

Hey.

I have the same problem.

But I found another solution to it!

Compare my two versions:

http://jsfiddle.net/Lexx918/yzVfc/ (works!)

http://jsfiddle.net/Lexx918/yzVfc/1/ (does not work)

Different one (well, two) lines.