How to get the trigger of a Fancybox?
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
}
}
});
});
Try something like:
$("a").click(function(){
var trigger = this;
$.fancybox({
href : this.href,
onComplete : function() {
if ( $(trigger).is(".someClass") ) {
// ...
}
}
});
});
精彩评论