[Silk UI Web] Support for disabled ToggleButton

[Silk UI Web] Support for disabled ToggleButton

  
Forge Component
(47)
Published on 11 Nov (3 weeks ago) by OutSystems Labs
47 votes
Published on 11 Nov (3 weeks ago) by OutSystems Labs
Looks like it doesnt honor the disabled attribute.

I added an if statement around the change handler to solve. Is there any reason why this shouldnt be part of the base?

New code highlighted (from ToggleScript):

function toggleButton(){
    var that = this;
    
    function onChange() {
        $(this).closest('label').toggleClass('changed');
        $(this).closest('label').parent().toggleClass('changed');
    }
    
    function onFocus() {
        /* set focus */
       /* $(this).closest('label').parent().css("outline-color", "#336600");*/
    }
    
    function onFocusOut() {
        $(this).closest('label').parent().css("outline-color", "transparent");
    }
    
    function initToggle() {
        $('.ToggleButton_label:not(.toggled) input').each(function(){
            if ($(this).is(':checked')) {
                $(this).closest('label').addClass('changed');
                $(this).closest('label').parent().addClass('changed');
            }
            
            $(this).closest('.ToggleButton_label').addClass('toggled');
            
            /* honor diabled attribute */
            if( !$(this).is(":disabled") ) {
                        $(this).on("change", onChange);
            }
 
            $(this).on("focus", onFocus);
            $(this).on("focusout", onFocusOut);
        });
    };
    
    osAjaxBackend.BindAfterAjaxRequest(initToggle);
    initToggle();
};
 
 
$(document).ready(toggleButton);
Hello Robert,

So far I wasn't able to replicate your issue.
When I use a disabled checkbox inside a toggleButton, the toggleButton is not selectable.

Can you provided us an example of  your implementation (screenshot or even a clean eSpace with the issue replicated)?

Best regards,
Samuel Jesus