Snappawapa Snappawapa - 5 months ago 17x
Javascript Question

Bootstrap modals: how to open with onClick=""

I need to be able to open a Twitter bootstrap modal window using the

or similar function. Just need the code to go into the
. I am trying to make a click-able
to open the modal.

Code Excerpts:

Div Code:

<div class="span4 proj-div" onClick="open('GSCCModal');">

Modal Div Code:

<div id="GSCCModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">


function open(x){


You don't need an onclick. Assuming you're using Bootstrap 3 Bootstrap 3 Documentation

<div class="span4 proj-div" data-toggle="modal" data-target="#GSCCModal">Clickable content, graphics, whatever</div>

<div id="GSCCModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
 <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>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      <div class="modal-body">
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>

If you're using Bootstrap 2, you'd follow the markup here: