Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 放大弹出窗口需要单击两次以打开图像滑块_Jquery_Asp.net Mvc_Magnific Popup - Fatal编程技术网

Jquery 放大弹出窗口需要单击两次以打开图像滑块

Jquery 放大弹出窗口需要单击两次以打开图像滑块,jquery,asp.net-mvc,magnific-popup,Jquery,Asp.net Mvc,Magnific Popup,我有一个场景,其中显示图像缩略图的代码被动态加载到DOM中。单击缩略图后,我想使用加载完整图像。以下是我的看法: <div class="Right-Panel-Section popup-gallery"> <h2>Images</h2> @foreach (var media in @Model.lsContentMedia) { <div class=" Float-Left"

我有一个场景,其中显示图像缩略图的代码被动态加载到DOM中。单击缩略图后,我想使用加载完整图像。以下是我的看法:

<div class="Right-Panel-Section popup-gallery">
        <h2>Images</h2>
        @foreach (var media in @Model.lsContentMedia)
        {
            <div class=" Float-Left" data-id="@media.MediaId">
                <a href="@media.ContentMediaFileName" >
                    <img src="@media.ContentMediaFileName" style="width:80px;height:80px;margin:5px;" title="@media.Description" class="gallery-item"/>
                </a>

            </div>
        }
    </div>

我已经正确地包含了样式和脚本文件。但是,我只能在最初对任何图像单击两次后才能查看图像。我总是希望它只需点击一下就可以工作。在此方面的任何帮助都将不胜感激。

尝试链接
。放大弹出(“打开”)
到弹出初始化

您的代码应为:

$("#Fixed-Container").on("click", ".popup-gallery", function (event) {
    $('.popup-gallery').magnificPopup({
        delegate: 'a',
        type: 'image',
        gallery: {
            enabled: true,
            navigateByImgClick: true,
            preload: [0, 1] // Will preload 0 - before current, and 1 after the current image
        }
    }).magnificPopup('open');
    event.preventDefault();
});

我不知道你是否还有这个问题,但我今天遇到了同样的问题。这就是我所做的

    $('body').on('click', "a.videolink", function(e){
      $.magnificPopup.open({
        items: {
          src: $(this).attr('href')
        },
        type: 'iframe',
      });
      e.preventDefault();       
    });
    $('body').on('click', "a.videolink", function(e){
      $.magnificPopup.open({
        items: {
          src: $(this).attr('href')
        },
        type: 'iframe',
      });
      e.preventDefault();       
    });