Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

aui-toggle change event is getting triggered even when value got changed with jquery in latest AUI

Deleted user Oct 08, 2018

aui-toggle change event is getting triggered even when value got changed with jquery in latest AUI version.

This was not happening in the previous version of AUI (7.6.3).

When I reset the aui-toggle value with below script in change, it is triggering the change event again and it is going into a recursive infinite loop.

AJS.$('#sometoggle').on('change', function(e) {

      $(thisObj).prop("checked", !thisObj.checked);

});

1 answer

0 votes

Hi Nagesh,

This appears to be the result of a change made in AUI 7.7.0; the toggle component was updated to fire the "change" event when the property was programmatically changed: https://ecosystem.atlassian.net/browse/AUI-3842

May I ask what your use-case is for updating the value of the toggle in response to its own value being updated? I'd like to understand the scenario a little more to determine whether this should be considered an undesirable behaviour in the toggle component.

If you're comfortable doing so, I would also recommend filing a bug against AUI directly: https://ecosystem.atlassian.net/secure/CreateIssue.jspa?pid=12771&issuetype=1

Cheers,

Daz

Deleted user Dec 06, 2018

The use-case is very simple. When we click the toggle, it opens a confirmation dialog whether we should save the change or not. If the user selects 'No', we should reset the toggle value to old value as toggle might have already changed by the time it landed in the on-change event.

Hi Nagesh, did you get any update or workaround?

No update on this, there is no direct solution for this. I used below workaround to resolve my issue.

- Just make change event off before changing the value and attach the actual handler after changing the value as below.

AJS.$('#sometoggle').on('change', function(e) {

      $(thisObj).off('change');

      $(thisObj).prop("checked", !thisObj.checked);

      $(thisObj).on('change', handlerMethodRef);
});

We've encountered this issue also. thanks for the workaround.

@Daz The use case is so straight-forward that you actually have an example for it in the documentation at https://docs.atlassian.com/aui/8.1.0/docs/toggle-button.html.

The WiFi example is broken, and it is stuck in an infinite loop.

Daz Atlassian Team Sep 05, 2019

Thanks for resurfacing this threadm @Snir Weiss. I agree that this behaviour is problematic, so I have raised https://ecosystem.atlassian.net/browse/AUI-5071, and will follow up with the team to determine an appropriate fix version and timeframe.

Thanks for your patience.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Statuspage

New feature: Slack notifications for Statuspage

We're excited to announce the release of a long-requested feature on Statuspage. Now visitors to your status page can subscribe to get notified in Slack when you report an incident or maintenance. Th...

82 views 0 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you