文档说调度器更改事件是“当用户选择调度器中的一个单元或事件时触发的”。
太棒了。问题是,事件也会在浏览器窗口调整大小时触发。我的应用程序现在认为,当浏览器窗口调整大小时,用户在单元格中单击。
如何区分这两种情况?
发布于 2016-08-19 01:58:25
我以为我在这里有答案,但没有骰子。不知道是什么原因导致调度程序在调整大小时触发更改事件。我在一个Marionette JS视图中展示它。也许这跟这件事有关?不确定。不应该这样的。
我知道这一切都是正确的,因为当点击日历时,日历可以正常工作--根据日历槽是否有事件或空白来显示正确的视图。但change事件在调整窗口大小时触发,导致我的应用程序触发视图更改。调度程序更改事件中的断点确认在调整窗口大小时触发。
下面,我试着根据在各种帖子中找到的一些处方,抛弃change事件,转而支持onClick。丑陋的代码,但它在Chrome上工作。不幸的是,它不能在其他浏览器中工作。为什么根本没有"onClick“事件呢?我刚刚看到一个与之竞争的调度器产品,它有一个。
唯一的Chrome解决方案:下面的 "e“是onClick事件对象:
//Get the element ID - the DOM ID of the thing that was clicked. You'll use it to
//dip into the scheduler data model to get the event specific data you're after.
var uid = e.toElement.parentElement.parentElement.attributes[2].nodeValue;
//Get a reference to the scheduler data model
var scheduler = $("#scheduler").data('kendoScheduler');
//Use the uid to find the event associated with the click action
var event = scheduler.occurrenceByUid(uid);
以下是帮助制定Chrome解决方案的帖子:
Call Scheduler events from EventTemplate
Kendo UI scheduler doesn't allow for reliable cell click event handling
这样做的问题显然是它不能在其他浏览器中工作。UID值(e.toElement.parentElement.parentElement.attributes2.nodeValue)在不同的浏览器中位于不同的位置。所以这个解决方案是行不通的。
我不知道像这样的产品怎么会没有onClick事件。很可能不得不使用不同的日历。非常令人沮丧。
手头的问题是我在一个Marionette js项目视图中呈现这个日历。当单击调度程序单元格项时,我会将用户带到不同的视图。但是调度程序用来处理点击的事件,"change",也会在浏览器窗口调整大小时触发。因此,在浏览器窗口调整大小时,我的应用程序会将用户带到不同的视图。不太好。没有工作可做。
https://stackoverflow.com/questions/39027071
复制