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

change event not working with BS4 radio button groups? #17599

Closed
tim-peterson opened this issue Sep 14, 2015 · 7 comments
Closed

change event not working with BS4 radio button groups? #17599

tim-peterson opened this issue Sep 14, 2015 · 7 comments

Comments

@tim-peterson
Copy link

Bootstrap v4 issue:

For the button group radios I can't get the input:radio change event to fire, so developers looking to do things like $('input').on('change', function ( //do something ) }); could get frustrated. This might not be BS4's fault per se, but just something that works in BS3 and may confuse people.

@tim-peterson tim-peterson changed the title change event not working with radio button groups? change event not working with BS4 radio button groups? Sep 14, 2015
@cvrebert
Copy link
Collaborator

You're referring to http://v4-alpha.getbootstrap.com/components/buttons/#checkbox-and-radio-buttons , correct?
We're still in the process of overhauling that widget to just use CSS sibling selectors instead of JavaScript.

@tim-peterson
Copy link
Author

@cvrebert Thanks, yes the BS v4 radio button groups. A CSS-only solution would be awesome, though I'd imagine many people would still want to use the jQuery change event, which is what seems to be busted.

Is it possible the BS v4 button JS widgets are blocking events (e.preventDefault?) such that change doesn't fire? Clicking the buttons does toggle the radio checked attributes so their essential function still works, but having the JS such that it doesn't prevent change events from firing seems valuable to preserve too.

@cvrebert
Copy link
Collaborator

Is it possible the BS v4 button JS widgets are blocking events (e.preventDefault?)

Quite probably.
A pure-CSS solution wouldn't suffer from that problem.

@tim-peterson
Copy link
Author

Perfect, thanks again! I don't know the etiquette so feel free to close this issue if that's what you typically do.

cappadona added a commit to cappadona/suma-proto that referenced this issue Nov 11, 2015
Toggle state for checkboxes as buttons is still WIP for bootstrap v4
(twbs/bootstrap#17599). Will stack and go for multiple columns next.
@tomas-marik
Copy link

tomas-marik commented Oct 13, 2016

Hi there,

I've just got stucked on this issue too. Problem seems to be in code part where "change" event being triggered in Button class:

if (triggerChangeEvent) {
      input.checked = !$(this._element).hasClass(ClassName.ACTIVE);
      $(this._element).trigger('change');
}

this._element points to LABEL so change event is not triggered on INPUT but instead on a wrapping LABEL element.

@mdo
Copy link
Member

mdo commented Nov 26, 2016

I believe this is a dupe of #16673? Problem sounds super similar with how the events are being handled for the input and label combo. See #16673 (comment).

@alexventuraio
Copy link

Hey there!
Has the issue being fixed? Because I still having it on Bootstrap v4.1.1. This is my example for reference.
The radio inputs do not get the checked attribute when clicking on them.

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

No branches or pull requests

5 participants