views:

38

answers:

1

I need to know which specific classes the anchor (which triggered the fancybox) has to do some more action wie the "onComplete"-function.

How do I get the trigger as jQuery-Object? $(this) seams to refer to the fancybox itself with no link to the original trigger.


Solution:

    $('a.fancybox').click(function(e){
    e.preventDefault();
    var trigger = $(this);
    $.fancybox({
        'href' : this.href,
        'onComplete' : function() {
            if (trigger.hasClass('specific_class')) {
                //do something
            } else {
                //do something else or nothing
            }
        }
    });
});
A: 

Try something like:

  $("a").click(function(){
       var trigger = this;
       $.fancybox({
           href : this.href,
           onComplete : function() {
               if ( $(trigger).is(".someClass") ) {
                  // ...
               }
           }
       });
  });
Mario Menger
Works like a charm, only thing to add is an event.preventDefault() so that the browser won't follow the link.Thank you!
Tim