Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.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_Html_Magnific Popup - Fatal编程技术网

Jquery 放大弹出图库不工作

Jquery 放大弹出图库不工作,jquery,html,magnific-popup,Jquery,Html,Magnific Popup,我正在尝试创建一个带有放大弹出灯箱图库插件的图库。我已经检查了Dmitry Semenov的文档,并完全按照他所说的复制了代码块。这是我的部分,其中包括所有文件: <head> <title>Gallery</title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link r

我正在尝试创建一个带有放大弹出灯箱图库插件的图库。我已经检查了Dmitry Semenov的文档,并完全按照他所说的复制了代码块。这是我的
部分,其中包括所有文件:

<head>
 <title>Gallery</title>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="styles/core_styles_gallery2.css">
  <link rel="stylesheet" type="text/css" href="styles/magnific-popup.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <script src="scripts/jquery.magnific-popup.js"></script>
  <script src="scripts/jQuery_gallery.js"></script>
</head>

画廊
正如您所看到的,这里有引导文件和我的css表,jQuery库文件,还有2.css和.js文件,用于开发人员说要包含的放大弹出窗口。下面是我的HTML库代码块(开发人员在其示例中使用了类“hoverZoomLink”):


最后,这是用于初始化弹出窗口的jQuery代码(位于
中包含的外部jQuery_gallery.js文件中):

$(document).ready(function() {
$('.popup-gallery').magnificPopup({
    delegate: 'a',
    type: 'image',
    tLoading: 'Loading image #%curr%...',
    mainClass: 'mfp-img-mobile',
    gallery: {
        enabled: true,
        navigateByImgClick: true,
        preload: [0,1] // Will preload 0 - before current, and 1 after the current image
    },
    image: {
        tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
        titleSrc: function(item) {
            return item.el.attr('title') + '<small>by Marsel Van Oosten</small>';
        }
    }
});});
$(文档).ready(函数(){
$('.popup gallery').magnificPopup({
代表:“a”,
键入:“图像”,
t加载:“正在加载图像#%curr%…”,
mainClass:'mfp img mobile',
画廊:{
启用:对,
NavigateByMgClick:true,
预加载:[0,1]//将在当前映像之前预加载0,在当前映像之后预加载1
},
图片:{
恐怖:“无法加载。”,
标题RC:功能(项目){
返回项目.el.attr('标题')+'由Marsel Van Oosten'编写;
}
}
});});

嗯,什么都没用。当我点击这些图片时,它们只是在另一个选项卡中打开。我不熟悉编程和web开发,我试图理解错误,但我不知道我做错了什么。请帮帮我

像开发者页面上的示例一样,尝试这样从基础开始(当然更改href和src):


能否尝试删除标题中的jquery.min.js链接中的1个?有时候,当jquery声明两次时,它会出错。编辑确保你没有在目录中丢失任何/,只是现在尝试删除它。没有任何变化。添加了一个答案来显示一些您可以尝试的代码。不,它不起作用。仍然只是在新的浏览器选项卡中打开每个图像。。。如果你说代码不是问题所在,那么问题所在是什么?这可能与我在单独的文件中使用jQuery脚本有关吗?我知道这是推荐的方法,但是我应该把它放在HTML中的标签之间吗?你包括缩放模块了吗?编辑你可以试着把它放在脚本标签里看看它是否有什么作用。我试着在浏览器开发者模式下检查控制台,它给了我一个错误:“Uncaught SyntaxError:Unexpected token$(document).ready(function() { $('.popup-gallery').magnificPopup({ delegate: 'a', type: 'image', tLoading: 'Loading image #%curr%...', mainClass: 'mfp-img-mobile', gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] // Will preload 0 - before current, and 1 after the current image }, image: { tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', titleSrc: function(item) { return item.el.attr('title') + '<small>by Marsel Van Oosten</small>'; } } });});
<a href="image.jpg" class="image-link">
   <img src="thumbnails.jpg" />
</a> 

// Initialize popup as usual
$('.image-link').magnificPopup({
  type: 'image',
  mainClass: 'mfp-with-zoom', // this class is for CSS animation below

  zoom: {
    enabled: true, // By default it's false, so don't forget to enable it

    duration: 300, // duration of the effect, in milliseconds
    easing: 'ease-in-out', // CSS transition easing function


    opener: function(openerElement) {
      return openerElement.is('img') ? openerElement : openerElement.find('img');
    }
  }

});
<a href="http://dummyimage.com/600x400/eee/000.jpg" data-group="1" class="galleryItem test">group 1 image 1</a> – 
<a href="http://dummyimage.com/600x400/000/fff.jpg" data-group="1" class="galleryItem test123">group 1 image 2</a>

<br/><br/>

<a href="http://dummyimage.com/600x200/000/fff.jpg" data-group="3" class="galleryItem">group 2 image 1</a> – 
<a href="http://dummyimage.com/600x900/000/fff.jpg" data-group="3" class="galleryItem">group 2 image 2</a>
var groups = {};
$('.galleryItem').each(function() {
  var id = parseInt($(this).attr('data-group'), 10);

  if(!groups[id]) {
    groups[id] = [];
  } 

  groups[id].push( this );
});


$.each(groups, function() {

  $(this).magnificPopup({
      type: 'image',
      closeOnContentClick: true,
      closeBtnInside: false,
      gallery: { enabled:true }
  })

});