Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Radiobuttons can't be selected once they are selected, then de-selected #1532

Closed
toddparker opened this Issue · 14 comments

7 participants

Todd Parker Kristian Andersen mobilizer John Bender James Weng Jason Tremblay Scott Jehl
Todd Parker

This is a recent and pretty major regression on all platforms:

  1. Go here: http://jquerymobile.com/test/docs/forms/forms-radiobuttons.html
  2. Click on the first radiobutton, then the second
  3. If you then click back on the first radiobutton, it won't be selected (visually anyway)

Maybe this is related to the active class tweak we recently landed.

Kristian Andersen

I have noticed similar behavior with custom multiple selectmenus, at least on mobile Safari.

Could it be related?

  1. Go here http://jquerymobile.com/demos/1.0a4.1/#docs/forms/forms-selects.html and click the multiple select.
  2. Select the first option
  3. Select the second option
  4. Try to deselect the first option again (fails)
John Bender johnbender closed this issue from a commit
John Bender johnbender remove checked state from radio button inputs that are not checked. u…
…se jquery attr accessor instead of expando to guarantee consistent values. Fixes #1532.
377c006
John Bender johnbender closed this in 377c006
mobilizer

This error is related to JQuery 1.6 RC1.

Selection is now fixed but the "change" event doesn't get triggered on reselecting the previously selected element.

$("input[name='selction-name']")
.live( "change",...

Todd Parker

@mobilizer - does John Bender's fix resolve the issue for you? Just wondering if your comment is here to help us understand why the issue cropped up or that it didn't work for you. This is why we're trying to get RC builds on jQuery core in early to catch breaking changes like this.

mobilizer

"Just wondering if your comment is here to help us understand why the issue cropped up or that it didn't work for you. "

Both ;)

1.) By reverting to jQuery 1.5.x the issue disappears completely

2.) John's fix partly fixes the issue. Everything is looking good with it. You can reselect the radio buttons again. But the "change" event is not triggered on selecting a previously selected element.

John Bender johnbender was assigned
Todd Parker

Gotcha. Ok, I assigned John to look at this again. Thanks for your help.

Todd Parker toddparker reopened this
John Bender

Mobilizer,

Thanks for sticking with this issue and keeping us informed, I'll put in a fix tonight with tests.

John Bender

mobilizer,

I suppose this is what I get for claiming I would have a fix tonight, but the expando property checked is misbehaving in chrome for me, but seems to be working in firefox. Hopefully I'll have more information tomorrow.

John Bender

http://i.imgur.com/ri4vN.png

For those who are interested or possibly better informed than I am as to why chrome might be behaving this way

mobilizer

There is something changed in JQuery 1.6 RC1... issue #8500 (RADIOS AND CHECKBOXES REVERT TO DEFAULT (HTML) STATE WHEN WRAPPED IN IE) http://bugs.jquery.com/ticket/8500

James Weng

Meet the same issue with jQuery 1.6.
Moved back to jQuery 1.5.2

Jason Tremblay

I was able to solve this with jQuery 1.6 by changing .attr to .prop in the checkboxradio plugin where the vclick function is bound to the label.

This issue is directly related to the changed behavior of jQuery .attr and .prop methods, which changed in jQuery 1.6 and 1.6.1. Basically .attr is for setting and querying the initial checked state of a radio button or checkbox, but .prop reflects the current checked state.

The issue is explained in detail here: http://blog.jquery.com/2011/05/12/jquery-1-6-1-released/

Scott Jehl scottjehl was assigned
Scott Jehl

I just looked into this one a bit. It looks like we're using prop already, and I'm not seeing any noticeable issues with change events firing. is this fixed then?

Demo here: http://jsbin.com/ivoki4/3/edit

Scott Jehl

closing this as I can't find a problem now. Let us know! Thanks

Scott Jehl scottjehl closed this
mobilizer

FIXED! :)

scottbw scottbw referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
Timmy Willison timmywil referenced this issue from a commit
John Bender johnbender remove checked state from radio button inputs that are not checked. u…
…se jquery attr accessor instead of expando to guarantee consistent values. Fixes #1532.
baf08dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.