Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checked and Unchecked is wrong... #34

Open
bit5 opened this issue Jan 9, 2018 · 2 comments
Open

Checked and Unchecked is wrong... #34

bit5 opened this issue Jan 9, 2018 · 2 comments

Comments

@bit5
Copy link

bit5 commented Jan 9, 2018

When using this checkbox, the checked and unchecked is reversed.

Look at this code
<input id="chk" type="checkbox" checked) />

You will see that the "NO" has been selected. And when you use in the js it is totally wrong! The No will be "TRUE" and Yes will become "FALSE".
$('#chk').checkboxpicker();
$('#chk').change(function () { alert ($(this).is(":checked")); });
$('#chk').prop('checked', false).trigger('change');

Any idea how to fix it?

Cheers

@bit5
Copy link
Author

bit5 commented Jan 10, 2018

I found the problem. The problem is that I am using "trigger" to ensure the "change event" is raised.
For quick workaround, I need to set the checked value to opposite value and then back to the actual value.

For example, the real value is FALSE, then do this:
$('#chk').prop('checked', true);
$('#chk').prop('checked', false);

As you can see, I've set the checked value to TRUE then set it back to FALSE.

I hope this help someone :)

@joweste
Copy link

joweste commented Jun 14, 2019

It doesn´t work to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants