Rajan Rajan - 1 year ago 283
Javascript Question

How to open a bootstrap modal on click of Glyphicons?

I my view I am showing a edit button using Glyphicons.

Now On the click of that icon I want to open a modal. How what should I do ?

Here is what I am doing :

<h3> <?php echo $this->session->userdata('site');?>&nbsp<i class="fa fa-pencil-square-o"></i></h3>

I tried this way:

<h3> <?php echo $this->session->userdata('site');?>&nbsp<i class="fa fa-pencil-square-o" data-target="#activateddevices"></i></h3>

But this does not work.

My Modal:

<div class="modal fade" id="activateddevices" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Devices Activated Using : <?php echo $this->session->userdata('site');?></h4>

<h4 class="modal-title">Activated: <?php echo $used."/".$allowed;?></h4>

<div class="modal-body">





Answer Source

Try the following:

 <h3>  <?php echo $this->session->userdata('site');?>&nbsp<i class="fa fa-pencil-square-o" data-toggle="modal" data-target="#activateddevices"></i></h3>