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

3.4 doesn't respect checked/unchecked in html any more #707

Open
morrow95 opened this issue Jun 3, 2019 · 6 comments
Open

3.4 doesn't respect checked/unchecked in html any more #707

morrow95 opened this issue Jun 3, 2019 · 6 comments

Comments

@morrow95
Copy link

morrow95 commented Jun 3, 2019

checked / unchecked specified in the html of the input is no longer respected with version 3.4. They will always show in an 'off' state regardless of the true state of the input when loaded.

An example is shown below. This worked perfectly fine with version 3.3.4, yet in 3.4 this will show the switch in an off state when it clearly has 'checked' in the html.

<input type="checkbox" class="make-switch" data-size="small" data-label-width="15" data-on-color="success" data-off-color="danger" data-on-text="Yes" data-off-text="No" name="name" value="1" checked>

@RouNNdeL
Copy link

Has anyone managed to fix it, other then using an older version?

@poggialim
Copy link

It is still not working... Unfortunately!

@morrow95
Copy link
Author

morrow95 commented Jul 5, 2019

I didn't bother comparing the js from the old/new, but something definitely changed within it to cause this issue.

@danielcsorba
Copy link

In the getClasses function, the filter's return should be return v !== null; instead of ==.

@souzaemarcal
Copy link

souzaemarcal commented Aug 27, 2019

Solved here with this:

$(function() {
	$('[data-switch="true"]').each(function () {
		$(this).bootstrapSwitch({ state: $(this).is(':checked') }).trigger('change');
	});
});

RouNNdeL added a commit to RouNNdeL/smart-home that referenced this issue Aug 27, 2019
@jybleau
Copy link

jybleau commented Oct 2, 2019

In the getClasses function, the filter's return should be return v !== null; instead of ==.

Shouldn't it be return v != null; to also include undefined value ? Because v seems to be undefined instead of null...

The strict operator still leads to classes like this: bootstrap-switch-undefined

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

6 participants