点击外面关闭所有Highslide

时间:2016-07-11 09:08:57

标签: highslide

我的网页上有一个Highslide插件,其中包含基本弹出式窗口,我需要的是当用户点击外部时,所有打开的弹出窗口都应关闭。

尝试过但没有运气:

   hs.close();

3 个答案:

答案 0 :(得分:0)

This might help: http://forum.highcharts.com/highslide-js-usage/multiple-hs-close-t22148/

But if you're not using a dimming background, clicking outside of an expander won't close it. How could it? You might be clicking on another thumbnail to open it - it can't tell the difference.

答案 1 :(得分:0)

在我的控制台上做了一些研究后,我想出了这个解决方案并且工作得非常好......

$(document).mouseup(function (e)
{
    if($(".highslide-wrapper").length==0)
        return;

    var container = $(".highslide-wrapper");

    if (!container.is(e.target) 
        && container.has(e.target).length === 0) 
    {
        for (var i = 0; i < hs.expanders.length; i++) {
            var exp = hs.expanders[i];
            if (exp) exp.close();
        }
    }
});

您还可以检查点击的元素是否是另一个缩略图..

答案 2 :(得分:0)

hs.Expander.prototype.onInit = function(sender) {
    for (var i = 0; i < hs.expanders.length; i++) {
        var exp = hs.expanders[i];
        if (exp) exp.close();
    }
};