2012-10-03 80 views
0

从我的下面的代码,它不会加载AJAX响应点击链接后的花式框。Jquery Fancy Box加载问题AJAX响应

<a>标识的ID是动态生成的。

但是,当我第二次点击相同的链接加载,但AJAX功能也被召回。

$(document).ready(function() 
{ 

    $(".cont").live('click',function(e) 
    { 
     //Cancel the default action (navigation) of the click. 
     e.preventDefault(); 

     var contentId = $(this).attr('id'); 


     $('#apps').load('/app/get-app-details', function(){ 
      $("#"+contentId).fancybox(); 
     }); 

    }); 


    }); 

<a class="cont" href="#device_detection" id="apps_<?= $regUsers->id; ?>"> Click to view apps</a> 

请给我一个解决方案。

+0

是这方面的需求将下降投票。它可能有重复的主题。但内容不同。我已经检查过类似的问题,这些不是我的问题。 – Shaolin

+0

什么版本的fancybox? – JFK

+0

版本1.3.4 – Shaolin

回答

0

这是working.May是另外一个人有有用

$(".cont").live("click",function() { 

     link=($(this).attr('href')); 



      $.fancybox({ 
      'width'    : '1000', 
      'href'     : link, 
      'height'   : '750', 
      'autoScale'   : false, 
      'transitionIn'  : 'none', 
      'transitionOut'  : 'none', 
      'type'    : 'iframe' 
      }); 





     return false; // don't follow the link! 
      }); 

直播中不再支持最新的jQuery。所以你可以使用

$("body").on("click",".cont",function() { 

     link=($(this).attr('href')); 



      $.fancybox({ 
      'width'    : '1000', 
      'href'     : link, 
      'height'   : '750', 
      'autoScale'   : false, 
      'transitionIn'  : 'none', 
      'transitionOut'  : 'none', 
      'type'    : 'iframe' 
      }); 





     event.preventDefault(); // don't follow the link! 
      });