0

I am trying to display table as a tooltip content.

However the table doesn't seem to show.

Here's the HTML:

<td>
    <a href="javascript:void(0);" data-toggle="tooltip1" class="red-tooltip" title="">5 Users</a>
</td>

The table:

<table id="tooltipContent" border="4" bordercolor="black" cellspacing="1" cellpadding="15px" style="width: 800px; display: none;">
     <tr><td>ravi_shrestha([email protected])</td></tr>
     <tr><td>ravi_shrestha([email protected])</td></tr>
     <tr><td>ravi_shrestha([email protected])</td></tr>
</table>

Tooltip initialization:

"fnDrawCallback": function( settings ) {
    $('[data-toggle="tooltip1"]').tooltip({
         content: $('#tooltipContent').html()
    });                
 },

Putting something in title attribute itself is working though.

1 Answer 1

1

Try using a callback function, properly add the js and css dependencies

$('[data-toggle="tooltip1"]').tooltip({
         content: function() { return $('#tooltipContent').html();}
});  

$('[data-toggle="tooltip1"]').tooltip({
  content: function() {
    return $('#tooltipContent').html();
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<td>
  <a href="javascript:void(0);" data-toggle="tooltip1" class="red-tooltip" title="">5 Users</a>
</td>

<table id="tooltipContent" border="4" bordercolor="black" cellspacing="1" cellpadding="15px" style="width: 800px; display: none;">
  <tr>
    <td>ravi_shrestha([email protected])</td>
  </tr>
  <tr>
    <td>ravi_shrestha([email protected])</td>
  </tr>
  <tr>
    <td>ravi_shrestha([email protected])</td>
  </tr>
</table>

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

5 Comments

in the snippet is working, have you got any console errors?
no.. console is empty.. it is working in the snippet though.. surprising..
that means the code is ether not called or you have some conflict in your code
Do we have to inject jquery-ui.css and jquery-ui.js too?
from what i can see yes

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.