Stranger
Stranger

Reputation: 862

Displaying bootstrap custom modal

Problem Description

I have two views. The first one contains a link, which when clicked, should display the second view which is my custom modal. Both files are in the same folder called school.

Code

firstView.html

<html>
  <head>Click the link</head> 
  <body>
    <div>
    <a  data-toggle="modal" href="secondView.html" data-target="#secondView" >Additional Details</a>
   </div>
  </body> 
</html>

secondView.html

<!-- Modal -->
<div id="secondView" class="modal hide fade" tabindex="-1" role="dialog" aria-    labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
 </div>
   <div class="modal-body">
      <p>One fine body…</p>
   </div>
  <div class="modal-footer">
     <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     <button class="btn btn-primary">Save changes</button>  
  </div>   

  </div>

Issue at hand

The problem is that when I click on my link, it does not display anything. I checked the console, and it does not display any errors. So, I am thinking this has to do with the way I connect these two views, probably something to do with href tag.

I would appreciate your help folks.

Upvotes: 0

Views: 1649

Answers (1)

Sami N
Sami N

Reputation: 1180

From http://twitter.github.com/bootstrap/javascript.html#modals:

If a remote url is provided, content will be loaded via jQuery's load method and injected into the .modal-body.

So you'd do

firstView.html

<html>
  <head>Click the link</head> 
  <body>
    <div>
    <a data-toggle="modal" href="secondView.html" data-target="#myModal" >Additional Details</a>
   </div>

  <!-- Modal -->
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-             labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">Modal header</h3>
    </div>
    <div class="modal-body">
      <!-- Here be modal content -->
    </div>
    <div class="modal-footer">
     <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
     <button class="btn btn-primary">Save changes</button>  
    </div>  
  </div>
  </body> 
</html>

secondView.html

<p>One fine body…</p>

Upvotes: 1

Related Questions