Checkbox change event not firing on unselect #1328

Closed
garyns opened this Issue Apr 1, 2011 · 10 comments

Projects

None yet

7 participants

@garyns
garyns commented Apr 1, 2011

I have noticed that checkboxes are only firing a change event when selected (ticked) and not when unselected.

For the below the change alert "Changed" is only shown when the checkbox is pressed to select.

<script>
  $(function() {
    $("#myCheckBox").change(function() {
      alert("Changed"); 
    });
  });
</script>


<div data-role="page" id="MyPage">
  <div data-role="content">
    <input type="checkbox" id="myCheckBox" name="myCheckBox">
    <label for="myCheckBox">Test</label>
   </div>
</div>
@toddparker
Contributor

Just posted your code into a JSBin to test it and it seems to fire the alert on both scenarios on Chrome. Is this happening only on a specific device?
http://jsbin.com/eruku4/edit

@jamiemnewman

Seems to be only with A4. Works fine with A3.

@garyns
garyns commented Apr 1, 2011

I get the problem with the current repository code on iPad and chrome.

@cmsfruit
cmsfruit commented Apr 5, 2011

I'm also experiencing this issue with JQM a4 on iPhone simulator. Here is what my checkbox element looks like

<input type="checkbox" name="my_checkbox" onchange="javascript: doSomething();" />

it never fires the custom onchange event.

@dimio85
dimio85 commented Apr 5, 2011

I think the source of the problem is commented here:

6121920

I hope it helps.

@johnbender
Contributor

fixed scoping issue that was causing the checkbox check to fail, tests to follow Closed by 141127b

@johnbender johnbender closed this Apr 6, 2011
@vikaskanani

@johnbender Your fix did not worked

@garyns
garyns commented Apr 7, 2011

I can confirm that the fix works in the current repository code.

@johnbender
Contributor

vikaskanani,

Can you post some more information so I can take a look?

@vikaskanani

Oh, sorry I should have replied soon, any way that worked correctly. I was missing one statement,

Nice work thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment