【问题标题】:How to detect the which button triggered the event in Kendo UI Window?如何在 Kendo UI Window 中检测哪个按钮触发了事件?
【发布时间】:2016-04-05 14:29:23
【问题描述】:

我在Kendo UI Window 上有两个或更多按钮,在某些业务逻辑之后,它们迟早都会调用.close() 事件。

例如,下面的屏幕:“关闭”按钮将直接关闭窗口,而“保存”按钮将检查某些条件然后触发关闭。

现在,我已经添加了我的条件

that.bind('close', function(){
     //check some condition
     // here if condition met, let the flow continue else call preventDefault()
});

当两个按钮都被单击时触发此拦截。如何检查哪个按钮触发了事件?

FYA,我已经扩展了 Kendo UI 窗口小部件,因此 that.bind() 拦截已经到位。

【问题讨论】:

    标签: javascript jquery kendo-ui kendo-window


    【解决方案1】:
    $("#closeBtnId").bind("click", function () {
    
    });
    
    $("#saveBtnId").bind("click", function () {
    
    });
    

    【讨论】:

      【解决方案2】:

      尝试在您的函数中添加一个事件,这样您就可以检查谁在调用该函数。像这样的:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-09-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多