Damian
Damian

Reputation: 191

Bootstrap 4 html tooltip is removing inline styles

I'm initializing tooltips with following code:

$('.tooltip').each(function () {
    $(this).tooltip({
      html: true,
      title: $('#' + $(this).data('tip')).html()
    });
});

Example of tooltip code:

<div class="tooltip">
 <div class="inner">
  <div class="tooltip__content">
   <ul>
    <li>
     <div class="rating">
      <div class="level" style="width: 85%;" data-width="85"></div>
     </div>
    </li>
   </ul>
  </div>
 </div>
</div>

My problem is that tooltip completely ignores my inline css/data styles e.g.

<div class="level" style="width: 85%;" data-width="85"></div>

is rendered as

<div class="level">

Is there solution to disable bootstrap tooltip removing of inline styles?

Upvotes: 5

Views: 1280

Answers (1)

Damian
Damian

Reputation: 191

Setting argument santize: false resolved issue:

$('.tooltip').each(function () {
  $(this).tooltip({
    html: true,
    sanitize: false,
    title: $('#' + $(this).data('tip')).html()
  });
});

Upvotes: 14

Related Questions