用程序触发剑道图表.系列点击事件

Programmatically Trigger Kendo Chart.seriesClick Event

本文关键字:系列 事件 程序      更新时间:2023-09-26

这是一个非常小而简单的问题。我在网上找不到任何东西,但我希望能够对我们的剑道图进行单元测试,特别是系列点击活动是否如预期那样有效。问题是我似乎找不到触发事件的方法。我试图通过jQuery和call.click((来定位图表系列。尝试这种方法没有给我任何帮助,所以在绝望的时刻,我尝试点击所有

$('*').each(function(){
    $(this).click();
});

没有这样的运气。这是图表选项片段

$scope.chartOptions = {
                //...
                // On Click add the criteria to the serach bar.
                seriesClick: function (series) {
                        console.log("seriesClick");
                        //Do stuff here                            
                        $scope.$apply();
                    }
                }
            };

当我在单元测试中尝试运行上面提到的jQuery代码时,我没有得到控制台输出。给你。

xit('should update the searchbar when a series item has been clicked', inject(function ($compile, $rootScope, $timeout) {
        var scope = $rootScope.$new();
        //Write out the directive
        //We have a directive that will replace this tag with the kendo-chart directive
        var ele = $compile('<chart></chart>')(scope); 
        angular.element(document.body).append(ele);
        scope.$digest();
        $timeout.flush(0);
        scope = ele.isolateScope();
        console.log('clicking everything');
        $('*').each(function () {
            $(this).click();
        });

我已经向telerik论坛提交了同样的问题,希望从"专家"那里得到一些建议,但我没有像SO那样快得到回复。

编辑我确实在Telerik论坛上看到了这篇帖子,我希望我需要做的不是"目前没有现成的支持"。

在telerik论坛上询问后,我终于得出了这个答案

 element.mousedown().mouseup()    //Trigger events for Chrome, Firefox and IE9
            .trigger(jQuery.Event("MSPointerDown", { originalEvent: {} })).trigger(jQuery.Event("MSPointerUp", { originalEvent: {} }))  //Trigger event for IE10
            .trigger(jQuery.Event("pointerdown", { originalEvent: {} })).trigger(jQuery.Event("pointerup", { originalEvent: {} })); //Trigger event for IE11

显然,它监听mousedown((mouseup((事件。然后在看到它不适用于IE10和11之后,我需要使用另一种触发mousedown((/mouseup((的方法