让我们说这是我的fancybox配置:
$(".fancybox").fancybox({
'transitionIn':'fade',
'transitionOut':'fade',
'speedIn':150,
'speedOut':150,
'changeSpeed':150,
'changeFade':150,
'overlayOpacity':0.1,
'overlayColor':'#000000',
'padding':0,
'margin':20,
'titleShow':false,
'centerOnScroll':true
});
Run Code Online (Sandbox Code Playgroud)
但是,我想做的是以某种方式将配置定义为fancybox默认值,因此当我绑定一个元素时,我只能这样做:
$(".newElement").fancybox();
它会自动拥有我的配置.
Luk*_*ott 20
Fancybox有一组内部默认值,可以轻松覆盖.
对于Fancybox 1.3,请使用:
jQuery.extend(jQuery.fn.fancybox.defaults, {
hideOnOverlayClick: false, //
overlayOpacity: 0.75, // <-- just an example
overlayColor: '#222' //
});
Run Code Online (Sandbox Code Playgroud)
对于Fancybox 2.0,删除了".fn":
jQuery.extend(jQuery.fancybox.defaults, {
type: 'ajax' // <-- for example
});
Run Code Online (Sandbox Code Playgroud)
当然,首先需要加载Fancybox javascript文件.
| 归档时间: |
|
| 查看次数: |
11031 次 |
| 最近记录: |