1

How do I add a bootstrap modal in the the javascipt on click. So far I was only able to alert ("hello") on click. How do i prompt out a modal box?

 graph.on("click", function (params) {
       var node = params['nodes'][0];
       displayInfo=false;
       if(node!=null){
        console.log('node:'+ params['nodes'][0]);
         x = params["pointer"]['canvas']['x'];
         y = params["pointer"]['canvas']['y'];   

         displayInfo=true;
         lastNode = nodes.get(node);
         lastClick = params['pointer'];
         //console.log(node);   
       }
       alert("hello");

       //add boostrap modal here    
     });
1

4 Answers 4

0

You don't need an onclick.

<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>
      <div class="modal-body">
        ...
      </div>
      <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>
      </div>
    </div>
  </div>
</div>

If you need an onclick event anyhow, use it like below:

    graph.on("click", function (params) {
$('#myModal').modal('show');
}

Reference: http://getbootstrap.com/javascript/#modals

Sign up to request clarification or add additional context in comments.

Comments

0

1 Comment

Co incidently we just shared same answer pal :p
0

First make the modal pop up div then , Configure and use .modal('show') For eg:-

 <a href="" data-target="#modalDiv" data-toggle="modal"> You can also use onClick call for jquery here.  </a>
  <div id="modalDiv">
       //some content
  </div>

In jquery use ,

     $("#modalDiv").modal('show');

Check this http://getbootstrap.com/javascript/#live-demo

Comments

0

You can use id like

$("#modal-id").modal("show");

Or you can use class name $(".modal-class").modal("show");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.