需要双击的自定义属性(featherlight灯箱)
所以,这是jsfiddle :
这是插件的链接( featherlight灯箱 )
问题是使用默认的targetAttr(即data-featherlight
featherlight),它只需单击一下即可。
但是,使用自定义targetAttr(例如本例中的data-single
),我必须在灯箱打开之前单击两次。
有人可以帮我解释它为什么这样做吗?
谢谢。
featherlight()有一个内置的点击触发器,所以你只需要直接调用插件:
jQuery('.something_else').featherlight({ targetAttr: 'data-single', });
请参阅: https : //jsfiddle.net/5e9e2k6y/9/
$('selector').featherlight()
(或使用data-featherlight
)用于绑定,如$('selector').click( function() {...} )
。
$.featherlight(...)
用于触发,如$('selector').click()
因此,绑定点击和触发器,或通过$('...').featherlight
绑定,但不要在click上绑定然后绑定在该处理程序中,就像你现在正在做的那样。