dxTooltip not working in IE, working in Chrome

女生的网名这么多〃 提交于 2019-12-23 02:28:05

问题


I have got a dxChart:

            var chart = $("#chartContainer4").dxChart();

of which I’m taking the legend rectangles:

            var PayerLegendBoxes = $("#chartContainer4 .dxc-legend g rect");

And using dxTooltip for showing on mouse hover.

            PayerLegendBoxes.each(function () {



                var nextElementHTML = this.nextSibling.innerHTML;

                var currElementTip = nextElementHTML + "tip";

                var currElement = this;



                var title = chart.append("<span style='display:none;' id=" + currElementTip + ">" + nextElementHTML + "</span>");



                var tooltipSimple = $("#" + currElementTip).dxTooltip({

                    target: currElement,

                }).dxTooltip("instance");



                $(currElement).unbind().hover(function () {

                    tooltipSimple.toggle()

                });



            });

This is working fine in Chrome but not in IE.

Is there a bug for cross browser functionality?


回答1:


Looks like the problem is in this line:

var nextElementHTML = this.nextSibling.innerHTML;

nextSibling.innerHTML returns undefined in IE. So, I suggest you use something like this:

// jQuery provides a "cross-browser" way here
var nextElementHTML = $(this).next().text();

And one more correction for this line:

var currElementTip = nextElementHTML + "tip";

nextElementHTML can sometimes contain a white space symbol. So, you should sanitize it:

var currElementTip = (nextElementHTML + "tip").replace(/\s/g, "_");

The updated sample is here - http://jsfiddle.net/5y8f4zt0/



来源:https://stackoverflow.com/questions/38407749/dxtooltip-not-working-in-ie-working-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!