How to parse obj variable into a .show() pop up in webix?

54 views Asked by At

I have a code like this.

$$('TLVab').attachEvent("onAfterEditStop", function(state, editor, ignoreUpdate) {
        $$('deleteLTMPopup').show();//TODO parse state into the pop up      
  });

UI.deleteLTMPopup= {id:'deleteLTMPopup',view:'window',head:'D',modal:true,position:'center',resize:true,move:true,autowidth:true,body:
    {rows:[
      {id:'delLifeTimeMCN',template:'W'},
      {cols:[
        {},
        {view:'button',value:'Cancel',width:60,click:function(){ this.getTopParentView().hide()}},
        {id:'deleteLTMBtnOK',view:'button',value:'Delete',width:60,click:function(id){
          var that = this;
          myFunction(state);//TODO have to parse state
          that.getTopParentView().hide();
        }},
      ]},
    ]}
  };

How do I pass state variable into the popup? I mean is there a .show(state) something like that. I have added //TODO inline comments in my code.

1

There are 1 answers

0
Stan On

For the onAfterEditStop event, the state argument is a simple object with new and old value.

{ value: any, old: any }

You cannot extend the .show() method of the window view, but you can add to the .config object before calling .show()

see https://snippet.webix.com/o21oe6fq

The onAfterEditStop handler

$$('TLVab').attachEvent("onAfterEditStop",function(state, editor, ignoreUpdate) {
    const stateMsg = `changed from ${state.old} to ${state.value}`; 
    webix.message(stateMsg);
   

    const $popup = $$('deleteLTMPopup');
    $popup.config.stateRaw = state;  // add state object to config
    $popup.config.stateMsg = stateMsg;  // or whatever
    $popup.show();   
  });

and the delete button inside the dialog can grab the data

  {id:'deleteLTMBtnOK',view:'button',value:'Delete',width:60,click:function(id){
      var that = this;
      const $popup = $$('deleteLTMPopup');
      webix.message('Again: ' + $popup.config.stateMsg);
      myFunction($popup.config.stateRaw); //TODO parse state
      that.getTopParentView().hide(); 
    }},