-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Cannot preventDefault on (click) event on ion-checkbox #10309
Comments
A potential workaround might be to bind to |
So for completeness, this is the workaround (using ionChange): handleToggleChange(evt) {
if(evt.checked !== myModel.checked) {
// Don't toggle just yet, let it happen reactively
evt.checked = myModel.checked;
myModel.toggleChecked();
}
} Hope it will be fixed properly in Ionic though. |
@Richie765 - thanks. I ended up doing something similar. Also of note -- ion-toggle probably has the same issue. |
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. Thank you for using Ionic! |
Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x
I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
The underlying _click fires first and sets checkbox._checked true or false regardless of (click) binding.
Expected behavior:
Ideally I could decide in code whether the click should result in checked or disabled state:
<ion-checkbox [checked]="selected" [disabled]="hidden" (click)="select(); $event.preventDefault();"></ion-checkbox>
Steps to reproduce:
<ion-checkbox (click)="$event.preventDefault();"></ion-checkbox>
should prevent the underlying click from firing and not affect _checked state.Other information:
Found underlying issue while testing fix for #9730 - @brandyscarney
Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):The text was updated successfully, but these errors were encountered: