Dhtmlx调度程序onEmptyClick无法访问IE8中的对象属性

时间:2014-05-03 12:10:51

标签: javascript jquery dhtmlx-scheduler

我已经实施了Dhtmlx Scheduler,可以从网站上预约。一切正常,但很少有方法在IE8中不起作用。

以下是我的onEmptyClick方法:

scheduler.attachEvent("onEmptyClick", function (date, native_event_object){

if(!$(native_event_object.target).hasClass('dhx_scale_holder')){
   var s=confirm("Are you sure, You want to take an appointment");
   if(s){ // proceed appintment}
}

});

问题在于hasClass。在其他浏览器上它可以正常工作。但是在IE8上,它返回" native_event_object.target" as Undefined,导致所有问题。

它返回" native_event_object"一切都很好我甚至可以在控制台看到目标。

任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我明白了。

IE不支持" .target"。所以我在我的代码之前添加了check。

scheduler.attachEvent("onEmptyClick", function (date, native_event_object){

     if(typeof native_event_object.target === 'undefined')
        var currTarget=native_event_object.srcElement;
     else
        var currTarget=native_event_object.target;

     if(!$(currTarget).hasClass('dhx_scale_holder')){

        var s=confirm("Are you sure, You want to take an appointment");
        if(s){ // proceed appintment}

     }


});