1

我是一个完全的 jQuery 新手,所以我为任何明显的疏忽道歉。现在我有一个网站,当单击某些链接时,我正在使用 jQuery Tools Overlay 加载外部 html (http://flowplayer.org/tools/demos/overlay/external.html)。这工作正常。

我遇到麻烦的地方是当我在 html5-canvas 中绘制的对象被单击时尝试触发覆盖。注意:我在检测单击对象时没有问题,我遇到的唯一问题是触发弹出窗口。

以下代码是我目前用来用外部页面填充 div 的代码,我想知道是否有人可以指出我正确的方向,使其不特定于链接。

谢谢!

//make all links with the 'rel' attribute open overlays
$(function() 
{
    // if the function argument is given to overlay,
    // it is assumed to be the onBeforeLoad event listener
    $("a[rel]").overlay(
    {
        mask: 'darkgrey',
        effect: 'apple',

        onBeforeLoad: function()
        {
            // grab wrapper element inside content
            var wrap = this.getOverlay().find(".contentWrap");

            // load the page specified in the trigger
            wrap.load(this.getTrigger().attr("href"));
        }
    });
});

更新:我最终得到的解决方案正如程序演示所描述的那样:将目标 div 转换为覆盖,并将负载设置为 true。要加载外部 html,只需保留上面的“onBeforeLoad”函数的内容。

4

1 回答 1

1

在这种情况下,您需要以编程方式而不是通过触发元素打开覆盖。

按照此演示中的说明和示例代码进行操作:http: //flowplayer.org/tools/demos/overlay/trigger.html

重要的注意事项是,在这种情况下,您选择的是覆盖元素而不是触发元素

还要注意load:true配置变量的添加

于 2011-07-19T00:15:08.863 回答