kexxcream
kexxcream

Reputation: 5933

Tooltip does not show with Bootstrap Slider

Problem:

I am using Bootstrap Slider, which can be found here https://seiyria.com/bootstrap-slider/. When using example 8, the tooltip does not show as it does on the website.

Minimal Working Example (MWE):

<!DOCTYPE html>
<html lang="sv">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>Judgement</title>
  <!-- Bootstrap Core CSS -->
  <link href="https://seiyria.com/bootstrap-slider/css/bootstrap.min.css" rel="stylesheet">
  <!-- Bootstrap Slider -->
  <link href="https://seiyria.com/bootstrap-slider/css/bootstrap-slider.css" rel="stylesheet">
</head>

<body>

  <input id="judgement" data-slider-id="judgementslider" type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="50">

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
  <script src="https://seiyria.com/bootstrap-slider/js/bootstrap-slider.js"></script>
  <script type='text/javascript'>
    $(document).ready(function() {
      $("#judgement").slider({
        tooltip: 'always'
      });
    });
  </script>
</body>

</html>

Example Snippet:

$(document).ready(function() {
  $("#judgement").slider({
    tooltip: 'always'
  });
});
body {
  padding: 100px;
}
<link href="https://seiyria.com/bootstrap-slider/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://seiyria.com/bootstrap-slider/css/bootstrap-slider.css" rel="stylesheet">

<input id="judgement" data-slider-id="judgementslider" type="text" data-slider-min="0" data-slider-max="100" data-slider-step="1" data-slider-value="50">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://seiyria.com/bootstrap-slider/js/bootstrap-slider.js"></script>

JS Fiddle:

http://jsfiddle.net/2u4xs9cv/1/

Desired outcome:

To always show the tooltip when the slider changes.

Upvotes: 5

Views: 8699

Answers (3)

Ondrej Rozinek
Ondrej Rozinek

Reputation: 601

This is still opened issue for Bootstrap 4.3.1 - #689. The Bootstrap v4 is not yet fully supported.

On the end of the discussed issue they are shown some solutions I use it following:

$("#ex12c").slider({ id: "slider12c", precision:2, step:0.01, min: 0.70, max: 1.00, range: true, value: [0.80, 0.90] });
#slider12c .slider-track-high {
    background: #5cb85c;
}

#slider12c .slider-selection {
    background: #ffc107;
}


.slider-handle::after{
    content: attr(aria-valuenow);
    position: absolute;
    bottom: calc(100% + 0.5em);
    left: 50%;
    transform: translateX(-50%);

    font-size: 0.75em;
    font-weight: 600;
    color: #393f50;
    background-color: white;
    box-shadow: 0px 0px 6px 0px rgba(182, 182, 182, 0.4);

    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 0.3em;
    width: 4em;
    height: 2.5em;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />   
    
    <!-- Bootstrap 4 CDN CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    
     <!-- Bootstrap 3 slider -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/10.6.2/css/bootstrap-slider.min.css" />  
</head>

<body>
  <br /> 
  <br />  
  <input id="ex12c" type="text"/>
  <!-- Bootstrap 4 CDN JS -->
  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  
  
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-slider/10.6.2/bootstrap-slider.min.js">
  </script>
  
<body/>
<html/>

Upvotes: 0

Elefhead
Elefhead

Reputation: 160

I know this is pretty late but I was looking for a solution and am posting here in hopes that this might be of help for someone else.

I set

.tooltip.in {
  opacity: 1;
}

and the tooltip started showing.

Upvotes: 15

Andy Thomas
Andy Thomas

Reputation: 1367

Using Bootstrap v4.2.1 and the latest version of bootstrap-spinner with their angular directive (in their slider.js file), I used the following HTML

<slider id="intervalSlider" 
    ng-model="refreshInterval" on-stop-slide="intervalChanged($event,value)"
    min="10" step="10" max="60" slider-tooltip="show" ></slider>

I found that the tootip and arrow did not display. I added the following CSS into my custom CSS file

   .slider .tooltip.in {
        opacity: 1;
    }

    .slider .tooltip.top .tooltip-arrow {
        bottom: 0;
        left: 50%;
        margin-left: -5px;
        border-width: 5px 5px 0;
        border-top-color: #000;
    }

    .slider .tooltip-arrow {
        position: absolute;
        width: 0;
        height: 0;
        border-color: transparent;
        border-style: solid;
    }

    .slider .tooltip.top {
        padding: 5px 0;
    }

Upvotes: 6

Related Questions