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

问题描述 投票:0回答:1

我有这样的代码。

$$('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 node.js ajax popup webix
1个回答
0
投票

对于 onAfterEditStop 事件,状态参数是一个具有新旧值的简单对象。

{ 值:任何,旧:任何}

不能扩展窗口视图的.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(); 
    }},
© www.soinside.com 2019 - 2024. All rights reserved.