Use localId as html data-* attribute

Hello webix support :)

How I can extend any component to include data-local-id attrbute in DOM ?
That would be of course exactly same value which would be used in localId config

Comments

  • I know how to do that for e.g. webix.ui.window

    webix.ui.window = webix.extend(webix.ui.window, {
        $init: function(){
            this.attachEvent("onShow", function(){
                const node = this.getNode();
                if(this.config.localId) {
                    node.setAttribute("data-local-id", this.config.localId);
                }
            })
        }
    });
    

    But then it works only for windows
    I would like to have same result for ALL components.
    Isn't that possible if all components are based on webix.ui.view ?

  • @michald1986
    it is possible using this undocumented feature.
    put this script as first line in html->head

    <script>
      window.webix_view = {
        $init: function(config){
          this.$ready.push(function(){
            config.localId &&
              this.$view.setAttribute("data-local-id", config.localId);
          })
        }
      }
    </script>
    

    https://jsfiddle.net/f3esk6v8/

  • That is awesome.
    Works exactly like I wanted it to work :smile:

    Thank you very much !

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion