如何将obj变量解析为webix中的.show()弹出窗口?

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

提问人:Jeevan 提问时间:5/16/2023 最后编辑:Jeevan 更新时间:5/19/2023 访问量:43

问:

我有这样的代码。

$$('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();
        }},
      ]},
    ]}
  };

如何将状态变量传递到弹出窗口中?我的意思是有没有类似的东西 .show(state)。我在我的代码中添加了 //TODO 内联注释。

JavaScript 节点 .js Ajax 弹出窗口 Webix

评论


答:

0赞 Stan 5/18/2023 #1

对于 onAfterEditStop 事件,state 参数是具有新值和旧值的简单对象。

{ value: any, old: any }

不能扩展窗口视图的 .show() 方法,但可以在调用 .show() 之前添加到 .config 对象

查看 https://snippet.webix.com/o21oe6fq

onAfterEditStop 处理程序

$$('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();   
  });

对话框中的删除按钮可以抓取数据

  {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(); 
    }},