mathlearner
mathlearner

Reputation: 7639

Showing a modal When onclick method is called of <a>

i am using a salesforce platofrm.in which i have access to only onclick function of a button .i have to launch a modal like this code

<!-- Button to trigger modal -->
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<!-- 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">
    <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>

instead of setting these attributes href="#myModal" role="button" class="btn" data-toggle="modal

how to show modal when user click on the link using onclick function of javascript please guideline

Upvotes: 2

Views: 73689

Answers (2)

Nageen
Nageen

Reputation: 1759

You can use toggle for hide show, don't need to use show and hide

$("#myModalID").modal('toggle');
$('#myModalID').modal('show');
$('#myModalID').modal('hide');

Upvotes: 0

Arun P Johny
Arun P Johny

Reputation: 388316

On click of the button you can use the show method as given in the documentation

$('#myModal').modal('show')

Demo: Plunker

Upvotes: 19

Related Questions