Update CSS in SettingsTab if a Dropdown is changed


I like to show/hide a Tab in my settings if a dropdown has a specific value to hide unnecessary settings from the plugin user. I implemented it like this but actually asked me how can I execute the function of the setting is changed. Actually it will be executed on startup but not if I change the dropdown value. I am sure for a Knockout expert it is very easy to tell me what I have to add. From my understanding there must be an observable that will trigger the function but...

Many thanks,

Check the knockout docs - I think you probably want the 'class' binding instead.


Also, when you are comparing with the settings value you will probably need to call it like a function, since it is an observable.

1 Like

It was the function part. I did not know that variables have to be accessed via a function wrapper to be observed. Many thanks.

I changed the binding also to class but it works fine with CSS also. But from the description class is better for the requirement.