Javascript 如何在剑道UI窗口中检测触发事件的按钮?
我有两个或两个以上的按钮,在某些业务逻辑之后,它们迟早都会调用Javascript 如何在剑道UI窗口中检测触发事件的按钮?,javascript,jquery,kendo-ui,kendo-window,Javascript,Jquery,Kendo Ui,Kendo Window,我有两个或两个以上的按钮,在某些业务逻辑之后,它们迟早都会调用.close()事件 例如,屏幕下方:“关闭”按钮将直接关闭窗口,但“保存”按钮将检查某些条件,然后触发关闭 现在,我已将我的条件添加到 that.bind('close', function(){ //check some condition // here if condition met, let the flow continue else call preventDefault() }); 当两个按钮
.close()
事件
例如,屏幕下方:“关闭”按钮将直接关闭窗口,但“保存”按钮将检查某些条件,然后触发关闭
现在,我已将我的条件添加到
that.bind('close', function(){
//check some condition
// here if condition met, let the flow continue else call preventDefault()
});
当两个按钮都被单击时,将触发此拦截。如何检查哪个按钮触发了事件
仅供参考,我已经扩展了剑道UI窗口小部件,因此.bind()拦截已就位。尝试在函数中添加事件,这将允许您检查调用该函数的人。大概是这样的:
$("#closeBtnId").bind("click", function () {
});
$("#saveBtnId").bind("click", function () {
});
that.bind('close', function(e){
var clickedButton = e.currentTarget || e.target || e.sender;
//check some condition
// here if condition met, let the flow continue else call preventDefault()
});
尝试在函数中添加一个事件,这样可以检查调用该函数的人。大概是这样的:
that.bind('close', function(e){
var clickedButton = e.currentTarget || e.target || e.sender;
//check some condition
// here if condition met, let the flow continue else call preventDefault()
});