Custom attribute requiring double click (featherlight lightbox)

落爺英雄遲暮 提交于 2019-12-02 03:02:56

问题


So, here is the jsfiddle:

Here is the link to the plugin (featherlight lightbox)

The issue is that using the default targetAttr (which is data-featherlight), it works with only one click.

However, with a custom targetAttr (such as data-single in this example), I have to click twice before the lightbox opens.

Could someone help me out why it is doing it?

Thank you.


回答1:


featherlight() has a build-in click trigger so you just need to call the plugin directly:

jQuery('.something_else').featherlight({
       targetAttr: 'data-single',                  
}); 

see: https://jsfiddle.net/5e9e2k6y/9/




回答2:


$('selector').featherlight() (or using data-featherlight) is for binding, like $('selector').click( function() {...} ).

$.featherlight(...) is for triggering, like $('selector').click()

So, bind on click and trigger, or bind via $('...').featherlight, but don't bind on click and then bind in that handler, like you're doing now.



来源:https://stackoverflow.com/questions/33682521/custom-attribute-requiring-double-click-featherlight-lightbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!