2

So, I saw this post which has this jsfiddles.

The answer was the following as below:

$('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.

I am having the same issue but I don't know how to bind on click and trigger like the answer.

So, if this is the js code (original code) then how would you bind on click and trigger?

jQuery('.something_else').click(function(e) {           
    jQuery('.something_else').featherlight({
                targetAttr: 'data-single',                  
            });                             
})  
Community
  • 1
  • 1
Emily Turcato
  • 581
  • 1
  • 6
  • 17

1 Answers1

3

Try:

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

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

madalinivascu
  • 32,064
  • 4
  • 39
  • 55
  • Thank you for the reply. I tried it here https://jsfiddle.net/5e9e2k6y/7/ but i still have to click it twice. =( – Emily Turcato Nov 13 '15 at 08:18
  • Thank you for the updated version. What should I do if I need to include a click function? Here is an example (last button) https://jsfiddle.net/5e9e2k6y/10/. I need the click function in order to make a variable and target specific button. – Emily Turcato Nov 13 '15 at 08:35
  • 1
    Thank you! =) you are the best! – Emily Turcato Nov 13 '15 at 08:47