I have a calendar on my website which uses ajax to switch between the different months and years. The calendar displays event titles for the respective days and when the user mousesover the title a lightbox should popup providing more information.
I have this all working up until the user changes the month or year with the buttons I provided. After that it seems fancybox isn't applied to the new elements.
I know it is because the elements were added to the dom after the initial fancybox definition and have taken care of it with code similar to this:
$('.date').live('focusin', function() {
var $this = $(this);
if(!$this.is(':data(datepicker)')) {
$this.datepicker();
}
});
This was used in conjunction with jQuery UI's datepicker.
I tried to replicate this code with this:
$('div#calendar').live('mouseover', function() {
$("a.event_link").fancybox({
'width' : 610,
'height' : 347,
'autoScale' : false,
'overlayOpacity' : 0.8,
'overlayColor' : '#000',
'type' : 'iframe',
'padding' : '5px',
'margin' : '5px',
'transitionIn' : 'elastic',
'transitionOut' : 'elastic'
});
$('a.event_link').live('mouseover', function() {
$(this).trigger('click');
});
});
With this code, its still functions properly when the page first loads but once the user changes the month or year, nothing happens.
I've tried many variations of this such as placing this inside a function and adding a setTimeout() right before the end, but I still get the same behavior.
The only thing I see different between the functional code and the non-functional is the use of $this, is it possible that I can't do a broad assignment of fancybox to multiple elements in this manor?
If anyone has any ideas, It would be greatly appreciated.