1

I am trying to generate unique IDs for each modal, as I will be loading in an address specific map to each modal. My issue is that when I click the link:

<a data-toggle="modal" href="#myModal_<? echo $meeting['ID'] ?>" ><? echo $meeting['Address'].", ".$meeting['City'] ?></a> 

it tries to take me to mypage.php/#myModal_8 (or whatever the given ID is, instead of pulling up that specific modal. The modals work great is I don't have the ID attached, but they won't load dynamic content that way.

 <a data-toggle="modal" href="#myModal_<? echo $meeting['ID'] ?>" ><? echo $meeting['Address'].", ".$meeting['City'] ?></a>
        </p>
        <div class="modal hide" id="#myModal_<? echo $meeting['ID'] ?>">
            <div class="modal-body">
                <? echo $meeting['Address'] ?>
            </div>
            <div class="modal-footer">
                <a href="#" class="btn" data-dismiss="modal">Close</a>
            </div>
        </div>

Any help on this would be much appreciated. Thank you!

Noah Davis
  • 1,054
  • 1
  • 15
  • 28
  • I'm not sure I understand your question. Could you clarify? Are you wanting to open a model, but with different content depending on a link you've clicked? – Martin Bean Jul 29 '12 at 19:55
  • Maybe I'm doing a stupid question but, have you included jquery library and bootstrap-modal.js/bootstrap.js? – Pigueiras Jul 29 '12 at 20:02

1 Answers1

1

It's all about the ID you are giving to the modal : id="#myModal_<? echo $meeting['ID'] ?>"

The # is only needed for the jQuery selector, not the ID. Which would give :

 <div class="modal hide" id="myModal_<? echo $meeting['ID'] ?>">

Further more, you should open your php tags with <?php for the reasons described here : Are PHP short tags acceptable to use?

Community
  • 1
  • 1
Sherbrow
  • 17,279
  • 3
  • 64
  • 77
  • Easy fix, thank you for the set of fresh eyes and the pointer on the short php tags. I'm a RoR guy, so I'm just getting into the swing of PHP again. – Noah Davis Jul 30 '12 at 03:22