首页 > 解决方案 > Sap-UI5: Adding a style class dynamically doesn't work

问题描述

I'm trying to add a css class dynamically using the controller.

Actually, I want the list item to have a green background when pressing the checkBox.

XML Code:

   <CheckBox text="{i18n>ChoosePaymentMethods}" select="onListSelectionChange" useEntireWidth="true" 
    id="checkBox"/>

Controller Code:

  onListSelectionChange: function (oEvent) {
                var oCustomListItem = this.getView().byId("custom");
                oCustomListItem.addStyleClass("lightBlueBackgroundListItem"); //doesn't work !!!
            },

Style CSS:

.lightBlueBackgroundListItem {
     background: green;
 }

标签: csssapui5

解决方案


推荐阅读