简体   繁体   English

Fancybox 3-将按钮添加到自定义HTML弹出窗口

[英]Fancybox 3 - Add buttons to custom HTML popup

I'm using fancybox 3, something like this 我正在使用fancybox 3,像这样

 <a href="#popup" data-fancybox="popup" data-buttons="['slideShow','fullScreen','thumbs','share']">Click me!</a> <div id="popup">MY POPUP with custom HTML</div> 

However, no buttons get added, and I get a jQuery error "Cannot use 'in' operator to search for 'length' in ['slideShow','fullScreen','thumbs','share']". 但是,没有添加任何按钮,并且出现jQuery错误“无法使用'in'运算符在['slideShow','fullScreen','thumbs','share']中搜索'length'”。 I've tried passing an object of options through data-options, but that did not work well. 我尝试过通过数据选项传递选项对象,但是效果不佳。 What is the correct syntax for what I am trying to do? 我要做什么的正确语法是什么? I want to add some of the standard buttons, like the thumbnails preview, share button (if that's possible with custom HTML), etc 我想添加一些标准按钮,例如缩略图预览,共享按钮(如果使用自定义HTML可以)等

Use correct JSON syntax, eg, replace ` and ": 使用正确的JSON语法,例如,替换`和“:

<a href="https://source.unsplash.com/xAgvgQpYsf4/1500x1000" data-fancybox="group" data-buttons='["slideShow","fullScreen","thumbs","share"]'>
  <img src="https://source.unsplash.com/xAgvgQpYsf4/240x160" />
</a>

Demo - https://codepen.io/anon/pen/oEaoVr?editors=1000 演示-https: //codepen.io/anon/pen/oEaoVr?editors=1000

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM