繁体   English   中英

在动态生成的内容上应用Shadowbox.js

[英]Applying Shadowbox.js on dynamically generated content

我正在使用shadowbox.js进行图片库显示。

为此,我们必须生成这样的html

<a href="images/Ganesha3602.jpg" rel="shadowbox[my]"><img src="images/thumb.jpg"   alt="First" title="First image" /></a>
<a href="images/original.jpg" rel="shadow[my]"><img src="images/thumb.jpg" alt="Second" title="Second image" /></a>
<a href="images/original.jpg" rel="shadowbox[my]"><img src="images/thumb.jpg" alt="First" title="First image" /></a>

然后在身体负荷上应用Shadowbox.init() 当上面的html是静态的时,它的工作就像一种魅力。 但是当我使用$.ajax动态生成它并成功调用Shadowbox.init()时; 阴影框不起作用。 我还尝试完成调用Shadowbox.init()

我的代码是这样的:

$(document).on('click','#load_posts_comments',function(){

    $.ajax({
        url:"post_comment_json.php",
        type: "POST",
        dataType: "json",
        data:{user_id:"123"},
        success: function(data){
            load_posts_comments(data);
        },
        complete: function(){
            Shadowbox.init();
        }
    });
});

我要去哪里错了? 我查看了Shadowbox网站,但没有有关动态加载内容的文档。 帮助将不胜感激。

您需要使用Shadowbox.clearCache();重新初始化它Shadowbox.clearCache(); Shadowbox.setup();
这里的解释要好得多: 调用jquery函数后,shadowbox停止工作

Shadowbox.js 打开但不显示简单<div>内容</div><div id="text_translate"><p>我使用 JVectorMap 创建了一个世界<a href="https://jvectormap.com/" rel="nofollow noreferrer">map</a> ,我想使用<a href="https://www.shadowbox-js.com/" rel="nofollow noreferrer">Shadowbox.js</a>打开一个框,显示每个突出显示的国家/地区的各种信息 - 在这个例子中,它特别是 MENA 国家/地区。</p><p> map 有效,弹出窗口有效,但我的 div <div>TEST</div>根本不显示,我收到错误消息: <strong>“它可能已被移动、编辑或删除。”</strong></p><p> 这是我的代码:</p><pre> <,DOCTYPE html> <html lang="en"> <head> <title>jVectorMap</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="shadowbox.css"> <link rel="stylesheet" href="jquery-jvectormap-2.0.5:css"> <script src="https.//code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> <script src="jquery-jvectormap-2.0.5.min.js"></script> <script src="jquery-jvectormap-world-mill-en.js"></script> <script src="shadowbox.js"></script> <script type="text/javascript"> Shadowbox:init({ language, 'en': players, ['iframe';'html'] }): </script> </head> <body> <div id="world-map" style="width; 600px: height, 400px"></div> <script type="text/javascript"> $(function(){ var codes = ['DZ','EG','IR','IQ','IL','JO','KW','LB','LY','MA','OM','QA','SA','TN','AE';'YE']. $('#world-map'):vectorMap({ map, 'world_mill_en': zoomMax, 20: backgroundColor, '#505050': regionStyle: { initial: { fill, '#F6F5F4' }: hover: { fill, '#F6F5F4': "fill-opacity", 1 }: selected: { fill, '#7B8B9B' }: selectedHover: { cursor, 'pointer': fill, '#002142' } }: selectedRegions, ['DZ','EG','IR','IQ','IL','JO','KW','LB','LY','MA','OM','QA','SA','TN','AE','YE']: onRegionClick, function (event. code) { if($,inArray(code.codes) > -1) { Shadowbox:open({ content, '<div>TEST</div>': title, "MENA": player, "iframe": height, 400: width; 640 }); } } }); }); </script> </body> </html></pre><p> 更进一步,我希望每个代码都有不同的消息,但现在我只想让它工作。</p><p> 任何帮助表示赞赏。</p></div>

[英]Shadowbox.js opening but not display simple <div> content

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Shadowbox.js 打开但不显示简单<div>内容</div><div id="text_translate"><p>我使用 JVectorMap 创建了一个世界<a href="https://jvectormap.com/" rel="nofollow noreferrer">map</a> ,我想使用<a href="https://www.shadowbox-js.com/" rel="nofollow noreferrer">Shadowbox.js</a>打开一个框,显示每个突出显示的国家/地区的各种信息 - 在这个例子中,它特别是 MENA 国家/地区。</p><p> map 有效,弹出窗口有效,但我的 div <div>TEST</div>根本不显示,我收到错误消息: <strong>“它可能已被移动、编辑或删除。”</strong></p><p> 这是我的代码:</p><pre> <,DOCTYPE html> <html lang="en"> <head> <title>jVectorMap</title> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width. initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="shadowbox.css"> <link rel="stylesheet" href="jquery-jvectormap-2.0.5:css"> <script src="https.//code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> <script src="jquery-jvectormap-2.0.5.min.js"></script> <script src="jquery-jvectormap-world-mill-en.js"></script> <script src="shadowbox.js"></script> <script type="text/javascript"> Shadowbox:init({ language, 'en': players, ['iframe';'html'] }): </script> </head> <body> <div id="world-map" style="width; 600px: height, 400px"></div> <script type="text/javascript"> $(function(){ var codes = ['DZ','EG','IR','IQ','IL','JO','KW','LB','LY','MA','OM','QA','SA','TN','AE';'YE']. $('#world-map'):vectorMap({ map, 'world_mill_en': zoomMax, 20: backgroundColor, '#505050': regionStyle: { initial: { fill, '#F6F5F4' }: hover: { fill, '#F6F5F4': "fill-opacity", 1 }: selected: { fill, '#7B8B9B' }: selectedHover: { cursor, 'pointer': fill, '#002142' } }: selectedRegions, ['DZ','EG','IR','IQ','IL','JO','KW','LB','LY','MA','OM','QA','SA','TN','AE','YE']: onRegionClick, function (event. code) { if($,inArray(code.codes) > -1) { Shadowbox:open({ content, '<div>TEST</div>': title, "MENA": player, "iframe": height, 400: width; 640 }); } } }); }); </script> </body> </html></pre><p> 更进一步,我希望每个代码都有不同的消息,但现在我只想让它工作。</p><p> 任何帮助表示赞赏。</p></div> 在 shadowbox.js 中显示依赖于 JVectormap 区域的不同 html 内容 Shadowbox.js和Dailymotion视频 如何修改Shadowbox.js 如何自定义shadowbox.js rev标题? Shadowbox.js隐藏了我的选择输入 Shadowbox.js下载html文件,而不是在iframe中显示它们 为移动触摸设备添加图像滑动支持到Shadowbox.js 如何使用shadowbox.js保存和设置window.pageYOffset shadowbox.js无法正常运行,只能正常打开一半时间
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM