2014-02-06 2 views
0

YouTube 동영상을 모달에 배치하는이 부트 스트랩 코드는 빈 플레이어를 모달로 표시합니다. $ banger 변수를 모달 코드로 전달했지만 비디오를 표시하지 않습니다. 무슨 일이야..? 자바 스크립트와 함께이 일을 클라이언트 측youtube video in a bootstrap modal 그냥 빈 플레이어를 보여줍니다

<?php $banger="sgr-1_chRMc"?> 

당신은 재고해야에 PHP 코드를 실행하려고하는 것처럼

<!-- Modal --> 
<div class="modal fade" id="Video_One" tabindex="-1" role="dialog"> 
<div class="modal-dialog"> 
<div class="modal-content" > 
<div class="modal-header"> 
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;  </button> 

<h3 class="modal-title" style="background:tan; margin:0 auto" id="myModalLabel"></h3> 

</div> 
<div class="modal-body"> 

<div class="flex-video widescreen"> 
<iframe src="http://www.youtube.com/embed/<?php echo $banger; ?>?&amp;fmt=22&amp;autoplay=0;HD=1;rel=0" frameborder="0" ></iframe> 
</div> 

</div> 
</div> 
</div> 
</div> 

<!-- Button trigger modal --> 
<a href="#" <?php $banger="sgr-1_chRMc"?>data-toggle="modal" data-target="#Video_One">test 1</a> 

<a href="#" <?php $banger="Yqbj9xLugU8"?>data-toggle="modal" data-target="#Video_One">test 2</a> 

<a href="#" <?php $banger="g4oMfY7q-Uo"?>data-toggle="modal" data-target="#Video_One">test 3</a> 

답변

0

는 것 같습니다. 이 내용을 쇼 이벤트의 모달에 바인딩해야합니다.

$('#Video_One').on('show.bs.modal', function (e) { 
    // get the video id from the clicked link 
    .............. 
    // apply the id to src 
    $('#Video_One').attr('src', 'http://www.youtube.com/embed/' + video_id + ?&amp;fmt=22&amp;autoplay=0;HD=1;rel=0' 

}) 
+0

잘 모르겠습니다. 이 코드를 페이지 맨 아래의 스크립트 컨테이너에두기 만합니까? 클릭 한 링크에서 동영상 ID를 얻는 방법은 무엇입니까? 좀 더 설명해 주시겠습니까? ".............."의 기본 예제를 보여줄 수 있습니까? – verlager