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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,507,371
Community Members
 
Community Events
180
Community Groups

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
AUG Leaders

Atlassian Community Events