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);
});
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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);
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.