Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I've two modals on a page, (i'm using bootstrap); clicking on any modal opens only the first. I don't understand js; is there an html fix?

This is the code for the first modal; all that changes in the next two modals is the image links inside, but only these show up.

<div id="modallinkleft">
  <a href="#myModal" data-toggle="modal">
  <img src="mylinks/cp/117s.jpg">
  <img src="mylinks/cp/23s.jpg">
  <img src="mylinks/cp/08s.jpg">
  </a>
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-body">
      <img src="mylinks/cp/117.jpg">
      <img src="mylinks/cp/23.jpg">
      <img src="mylinks/cp/08.jpg">
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">x</button>
    </div>
  </div>
</div>
like image 511
kartik Avatar asked May 11 '13 05:05

kartik


1 Answers

Each modal should be given a different id and each link should be targeted to a different modal id. So it should be something like that:

<a href="#myModal" data-toggle="modal">
...
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
...
<a href="#myModal2" data-toggle="modal">
...
<div id="myModal2" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
...

In this way, if you click the first link, it should pop-up the first modal and if you click the second - the second modal is popped up.

like image 107
graumanoz Avatar answered Oct 29 '22 16:10

graumanoz