javascript - Fancybox inside a div, Does not work after onclick event -
hello , thank time. developing long list of videos on webpage. had div tag includes lets 10 video links. these links open iframe html has actual video embedded there. parent page has no videos, links, anchors have href="video.html", video.html has video in it. loads fine initially, afterwards need sort function. made sort function sorts videos. onclick videos change. way works content inside div changed using .innerhtml = "". content change, , able see new video links , preview images, when click on images, href link opens in new window, or parent window, not sure, not important because fancybox not open, tried number of different things still not results. question asking why fancybox not work when anchor tags changed dynamically. please help
okay thank you, not sure how use .live , .bind it. now, here code
<div id="mask"> </div> <script type="text/javascript" language="javascript"> populate(); function populate() { var mask=document.getelementbyid('mask'); mask.innerhtml = ''; mask.innerhtml = allvideos[3] + allvideos[0]; } //then allvideos[3] example <a href="videos.html"/> //so part works. if try , </script> <div onclick="change();" >doesntmatter</div> <script> //and change function function change() { var mask=document.getelementbyid('mask'); mask.innerhtml = ''; mask.innerhtml = allvideos[3] + allvideos[0]; } </script> so same exact function fancybox stops working. , right fancybox code gets called in beginning $(document).ready(function() { $("a.videos").fancybox({
==============================================solved=================================== had change $(document).ready(function() {$("a.videos").fancybox({ $(document).ready(function() { $('a.video').live('mouseenter', function(){ $(this).fancybox({
right after changed elements javascript (for example, when did .innerhtml = "") have call initial code again, including call fancybox plugin,
you try use .live() instead of .bind().
Comments
Post a Comment