Jquery 将额外数据注入fancybox
嗨,我想向facybox title函数注入一个额外的数据。deneme是我想注入的变量,但没有成功Jquery 将额外数据注入fancybox,jquery,fancybox,Jquery,Fancybox,嗨,我想向facybox title函数注入一个额外的数据。deneme是我想注入的变量,但没有成功 <a rel="example_group" title="Title comes here" data-deneme="<?php echo $galleryitem['idphotos']; ?>">sdasd</a> $("a[rel=example_group]").fancybox({ 'transitionIn'
<a rel="example_group" title="Title comes here" data-deneme="<?php echo $galleryitem['idphotos']; ?>">sdasd</a>
$("a[rel=example_group]").fancybox({
'transitionIn' : 'none',
'transitionOut' : 'none',
'titlePosition' : 'over',
'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
var deneme=$(this).data('deneme');
return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' ' + title : '') + '</span><span stye="color:#FFF; cursor:pointer;" onclick="javascript:popUpWindow("<?php echo base_url();?>selectproductoptions/'+ deneme +'.html",10,10,660,550);">+ add to cart</span>';
}
});
如果使用fancybox v1.3.4: 不幸的是,您不能使用
$(this)
(也不能使用this
)引用从中调用fancybox的元素(假设这是一个设计错误),因此您必须引用整个选择器$([rel=example\u group])
。要过滤当前元素,请使用通过titleFormat
API函数传递的currentIndex
参数,如:
。。。或:
'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
var deneme = $("a[rel=example_group]:eq("+currentIndex+")").data('deneme');
return '...etc'
}
。。。你喜欢什么都行
如果使用fancybox v2.x+ 您可以使用
$(this.element)
对于您的标题
,使用回调beforeShow
添加变量,如下所示:
$("a[rel=example_group]").fancybox({
// other API options
beforeShow: function(){
var deneme = $(this.element).data('deneme');
this.title = 'some html' + this.title + 'other html' ... etc
}
});
如果使用fancybox v1.3.4: 不幸的是,您不能使用
$(this)
(也不能使用this
)引用从中调用fancybox的元素(假设这是一个设计错误),因此您必须引用整个选择器$([rel=example\u group])
。要过滤当前元素,请使用通过titleFormat
API函数传递的currentIndex
参数,如:
。。。或:
'titleFormat': function(title, currentArray, currentIndex, currentOpts) {
var deneme = $("a[rel=example_group]:eq("+currentIndex+")").data('deneme');
return '...etc'
}
。。。你喜欢什么都行
如果使用fancybox v2.x+ 您可以使用
$(this.element)
对于您的标题
,使用回调beforeShow
添加变量,如下所示:
$("a[rel=example_group]").fancybox({
// other API options
beforeShow: function(){
var deneme = $(this.element).data('deneme');
this.title = 'some html' + this.title + 'other html' ... etc
}
});
fancybox v1.3.4。。。还是使用旧的API选项?fancybox v1.3.4。。。还是使用旧的API选项?