define('css', 'my-css')

seems like define just adds css, never removes or replaces any css, is that correct?

  • if so, what’s the best way to change the css.
  • removeCss is only an option if you actually know what the current css is, no?

David

hmm, wondering if this is a bug:

   webix.html.removeCss($$("id").getNode(), view.config.css)
   webix.html.addCss(view.getNode(), 'new_css')

for some reason the removeCss function is not removing the old css

The following seems to be a work around for node.removeCss not working:
Note: using Lodash:

function set_css(view_id, new_css) {
    var view = $$(view_id)
    var node = view.getNode()
    
    // current css as reported by webix
    var current_css = view.config.css 

    // do nothing if the css is the same:
    if( current_css == new_css )
       return 

     // get the current classes by parsing the node's 'className' attribute:
      var classes:string[] = node.className.split(" ")

      // if there is a current_css then remove it:
      if( current_css && (_.some(classes), ( c ) => c == current_css) ){
         node.className = _.replace(node.className, current_css, '')
      }

       // this will add the new_css, and also set the config.css 
       // so that we can remove it later
       view.define('css', new_css)
   }

Hi,

The removeCss works for me, please check the next snippet

http://webix.com/snippet/1eb26578

by any chance, are you using some special symbols in the name of a CSS class?