2017-07-17 7 views
0

私はこのwebsiteのいくつかのモーダルウインドウをテストしています。ご覧のとおり、モーダルは再生ボタンをクリック/タッチするとトグルされます。Bootstrap Modal:列全体をクリック可能にする

私の質問は、列全体をクリック可能にしてモーダルを開くことですか?

私は、結果を出さずにdata-targetでdiv全体のデータトグルを定義しようとしました。

これは、HTMLコードです:あなたはそのオープンモーダルクリックであなたが望むあなたのdivのidを割り当て、次のように行うことができます

<!-- Button trigger modal --> 
<i class="fa fa-play btn btn-lg" aria-hidden="true" type="button" data-toggle="modal" data-target="#myModal"></i> 
</div> 
<!-- Modal --> 
<div class="modal fade modal-video" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
<div class="modal-dialog modal-lg" role="document"> 
<div class="modal-content"> 
<div class="modal-header"> 
    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
    <h4 class="modal-title" id="myModalLabel">Title 1</h4> 
    </div> 
    <div class="modal-body"> 
     <video controls="" width="100%" id="video"> 
     <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4"> 
     </video> 
     <div class="modal-text"> 
      <p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr.</p> 
     </div> 
    </div> 
    <div class="modal-footer"> 
    <button type="button" class="btn button-eh-magenta">Go to Shop</button> 
    <a href=""><button type="button" class="btn button-eh-magenta">Share</button></a> 
    </div> 
</div> 

答えて

0

$('#specified_div').click(function(){ 
    $('#targetmodal').modal(); 
}); 

別の方法は、の要素モーダルをクリックして、任意の要素にdata-toggle="modal"data-target="#targetmodal"を追加することですが開きます。


ここで、ブートストラップサイトの引用である:データを介して

はJavaScriptを記述することなく、モーダルを有効に属性。ボタンのようなコントローラエレメント上に data-target="#foo"またはhref="#foo"と一緒に トグルに特定のモーダルをターゲットにして、data-toggle="modal" を設定します。私はすでに割り当てデータ・トグルおよびデータで試してみました

$('#myModal').modal(options) 
+0

こんにちは、 :

<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button> 

経由のJavaScript

には、JavaScriptの1行を持つID myModalとモーダルを呼び出します-targetをdivに設定しますが、その結果はモーダルを閉じることができません。 – Roxana

+0

コンソールに何かエラーがありましたか? –

+0

エラーはありません。あなたは一見することができます、私はあなたが示唆したように、最初の列のデータターゲットとデータトグルを適用しました。それはモーダルが終わらないことが起こる。 http://cms.nowcommu.myhostpoint.ch/ – Roxana

関連する問題