【问题标题】:how to detect onClick or click event on a view added to kendo window如何在添加到剑道窗口的视图上检测 onClick 或单击事件
【发布时间】:2014-12-04 06:20:15
【问题描述】:

我有一个剑道窗口弹出窗口,我会在某些事件被触发时打开它。在那个剑道窗口中,我使用 window.content(new View().el) 添加了一个视图。视图包含几个 div,其中一个具有 id leftarrow。 Onclick on div #leftArrow 我需要做点什么。但我无法检测到 onclick 事件。 我在视图中添加了单击事件侦听器并为其提供了回调函数。当我在 click 上放置事件监听器断点时,事件正在触发,但不知何故它没有在视图中被监听。谁能告诉问题出在哪里??

/*This is the controller file where I have created the kendo window and added view in it*/ 
var window = uiLayer.extWindow({
                elem : $('#popUp'),
                actions:["Close"],
                modal: true,
                animation: false,
                resizable: true,
                close: that.onClose,
                width: "95%",
                height: "95%",
                minHeight : "35%",
                minWidth : "60%",
                position:{
                    top:"1%",
                    left:"1%",
                    height:"100%",
                    width:"100%"

                }
              });
            window.open();
            window.content(new PopUpScrollLayoutView(this).el);
/*This is the view in which I have added various templates which contain the div #leftArrow . I have added click event in the events and given it a callback method. 
*/
  PopUpScrollLayoutView = Marionette.LayoutView.extend({

            initialize : function(options){
                console.log("Initialising EventContentView");
                console.log(options.getAllWidgets());
                var allWidgets = options.getAllWidgets();
                this.render(allWidgets);

            },
            events: {
                "click #leftArrow":"leftArrowClicked"
            },

            tagName: "div",
            className: "scrollContent",
            regions : {
                leftArrow : "#leftArrow",
                mainArea : "#mainArea",
                rightArrow : "#rightArrow",
                footer : "#footer"
            },
            render : function(allWidgets){
               this.$el.append(template());
                this.$el.append(mainAreaTemplate());
                this.$el.append(FooterAreaTemplate());
            },
          leftArrowClicked:function(e){
                console.log("Inside left arrow");
            }
    });

【问题讨论】:

    标签: javascript jquery kendo-ui


    【解决方案1】:

    您可以为此目的使用 jQuery:

    $("#leftArrow").click(leftArrowClicked);
    

    【讨论】:

    • 就在window.content(new PopUpScrollLayoutView(this).el);之后,并确保在脚本主体的任何地方取出leftArrowClicked()函数。
    • 不,这并没有解决问题
    • 在添加所有区域后尝试在渲染中。
    • 能否上传完整的运行源代码以便我提供帮助?一个可以演示案例的示例。
    • 事件被触发,但没有被当前视图捕获。该事件正在冒泡到 kendo WINdow 组件的外包装 div。我不能在木偶视图中添加事件处理程序并处理事件吗??
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    相关资源
    最近更新 更多