我有这样的代码。
$$('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 内联注释。
对于 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();
}},