Call Modal and Tooltip on the same data-toggle

6

I have a button that calls a modal like this:

<button type="button" data-toggle="modal" data-target="#revisao>Revisao</button>

To call a Tooltip, use:

<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="left" title="Tooltip on left">Tooltip on left</button>

How to call Modal and Tooltip on the same button?

    
asked by anonymous 11.12.2015 / 11:52

1 answer

6

Leave the same modal structure, include only a new data-type that will be your data-toogle , in my example, I used data-tt="tooltip" now just add title and call in js.

Example:

$("[data-tt=tooltip]").tooltip();
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<br><br>

<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal" data-target="#myModal" data-tt="tooltip" title="Olá Mundo!">Modal</a>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
        </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>
    
11.12.2015 / 12:09