question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Being able to prevent ion-toggle from toggling

See original GitHub issue

Hi,

I know there is the “disabled” property to completely prevent any click on the ion-toggle element but in some cases I would like to let the user clicks on the toggle, then it does an async process, and switch only if the process has succeeded.

For example, the user wants to turn ON an option that requires additional information (little form through a modal), if the user leaves the process, I would like to let the toggle on OFF (without seeing a quick transition OFF/ON/OFF).

I tried to catch the click event to stopPropagation… but it doesn’t work, the toggle continues to move.

Maybe the easiest solution would be to make us able to trigger stopPropagation from the $event passed inside ionChange.

What do you think 😃 ?

Thanks,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
khaledosmancommented, Sep 8, 2020

had the same usecase, listening to click event instead of ionChange and using

e.stopImmediatePropagation();
e.stopPropagation();
e.preventDefault();

did the trick however this only works if the user clicks on the toggle, if he swipes it the same issue exists and even worse it will not be caught by the click handler

0reactions
ionitron-bot[bot]commented, Dec 16, 2021

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Being able to prevent ion-toggle from toggling #17748 - GitHub
Hi,. I know there is the "disabled" property to completely prevent any click on the ion-toggle element but in some cases I would...
Read more >
ionic framework - unable to prevent ion-toggle from toggling
Another solution would be to bind the toggle with [(ngModel)] and set it back to false when the validation runs and the toggle...
Read more >
Using event.preventDefault to prevent ion-toggle to toggle
I am using ion-toggle in my app . when user clicks(checks) on the ion-toggle , i have written ionChange hook on the ion-toogle...
Read more >
ion-toggle for State change problem : r/ionic - Reddit
I am trying to use ion-toggle. I am initializing his state based on an isStatusInProgress variable. Until here, everything is fine. When I...
Read more >
Not change Ionic toggle value in workflow - Bubble Forum
Use the conditional Workflows on your main workflow. The ionic toggle has this feature built in btw. Just use autobind.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found