The following code is working as far as setting the disabled
attribute on the chosen element however it is not updating until the next render cycle so its behind one click/change of the checkbox.
$(document).on('change', '#<%= checkSetSmtpCredentials.ClientID %>', function() {
let isChecked = $(this).is(':checked');
$('#<%= ddlSmtpAuthenticationMode.ClientID %>').prop('disabled', isChecked);
});
jQuery is version 2.1.3 fwiw.
Current behavior:
- Checkbox has default state of unchecked, chosen element has default state of
disabled="disabled"
- Click checkbox. Checkbox becomes checked
- chosen element stays disabled
- Click cb. Cb becomes unchecked
- Chosen element is now no longer disabled
- State is now opposite of what it should be
Chosen element is updated one render cycle behind the cb being changed.
Expected behavior:
When cb is checked, chosen element must be updated on that same render cycle.