2016-10-21 4 views
0
<table id="result"> 
<a href='#' class='pop'><span class='fa fa-eye'><img src='image link here' style='display:none'></a> 
</table> 

上記のhrefを使用してイメージをモーダルで開きます。画像ajaxを使用してコンテンツを読み込むときにダイアログモーダルでプレビューが動作しない

Modal For Image Preview: 
<div class="modal fade" id="imagemodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="position:absolute"> 
      <div class="modal-dialog"> 
       <div class="modal-content">    
       <div class="modal-body"> 
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button> 
        <img src="" class="imagepreview" style="width: 100%;" > 
       </div> 
       </div> 
      </div> 
      </div> 

jqueryの(その1 +その2)下記のザ・親ページで動作しますが、テーブルのコンテンツはプレビューが機能していないAJAXを使用してロードされるたびに。

jQuery for modal show: 
part1 : $(function() { 
     $('.pop').on('click', function(e) { 
      e.preventDefault(); 
      $('.imagepreview').attr('src', $(this).find('img').attr('src')); 
      $('#imagemodal').modal('show'); 
     });  
    }); 

パート1は親ページで動作します。

Part2 :$("#results").on("click",".pop", function(){ 
     //alert("hello"); 
     e.preventDefault(); 
     $('.imagepreview1').attr('src', $(this).find('img').attr('src')); 
     $('#imagemodal1').modal('show'); 
    }); 

part2もアラートを表示していますが、画像プレビューは機能していません。 ご協力いただければ幸いです。

答えて

0

問題の一部は、パート2のクラスとIDの参照ですか?あなたの例には、クラスimagepreview1とID imagemodal1は存在しません。彼らはimagepreviewimagemodalであるべきですか?

何が問題になりますか? Part 2は画像プレビューを表示していませんが、Part 1にも問題がありますか? ajaxがあなたのパート1を壊している場合、あなたのajaxの読み込みのサンプルを与えることができますか?

関連する問題