Bind Fancybox to different event
I'm using the fancybox jQuery plugin and right now, it's being called with a click
event. I want to change this so that fancybox is called with a different event but I'm not sure where in the source code fancybox is being binded to the click event. Can someone point out the line that thi开发者_StackOverflow社区s is happening?
Thanks!
Two answers: ;)
You can use the "trigger" function of jQuery to launch the click event you have configured for the fancybox, so if your fancybox is initialized as:
$("#someID").fancybox();
you can open that fancybox with only a:
$("#someID").trigger("click");
OR you can make a manual call for wathever event you want:
$.fancybox(
{ 'href' : $("some jquery reference"),
'autoDimensions' : false,
'width' : 350,
'height' : 'auto'
});
There are part of the trip'n tricks of Facnybox page: tips & tricks
I've not used fancybox but most of these plugins can usually be fired manually without having to be bound to an element. It's very unlikely you ever need to go rooting about in source code.
You don't say what you want to do but I'm sure you could do something like
$('#trigger').mouseover(function() {
$.fancybox(
'<h2>Hi!</h2><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis mi eu elit tempor facilisis id et neque</p>',
{
'autoDimensions' : false,
'width' : 350,
'height' : 'auto',
'transitionIn' : 'none',
'transitionOut' : 'none'
}
);
});
Fancybox code taken from http://fancybox.net/blog
精彩评论