Knockout style binding: firefox doesn’t set background-color ?

Knockout style binding: firefox doesn’t set background-color ?

Asked on December 19, 2018 in knockout js.
Add Comment


  • 2 Answer(s)

        Try to use the backgroundColor attribute rather than background-color .

        See this  Demo.

        This is differ from Knockout-specific thing. By seeing  in the relevant KO source code file, The binding sets style like this:

    element.style[styleName] = styleValue || "";
    
    

        The firefox manage this element.style[…] syntax various from Chrome, as can be seen if you type the following in both console windows:

    document.body.style['background-color'] = 'red'
    
    

        This works in Chrome, not in Firefox.

    Answered on December 19, 2018.
    Add Comment

        Utilize the backup syntax to find CSS class names works in Firefox:

    <div class="littleBox" data-bind="style: {backgroundColor: colorText}"></div>
    
    

        For knowing the answer , Visiting the source code is necessary.

    Answered on December 19, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.