Search code examples
jquerycsstwitter-bootstraptwitter-bootstrap-2bootstrap-slider

Overlapped part of tooltip of slider and his position in bootstrap-slider plugin


I use Twitter Bootstrap 2.3.2 and bootstrap-slider plugin in modal window. The problem is that part of tooltip of slider is overlapped behind header of modal window and has wrong position.

enter image description here

I tried to add this rule, but it didn't help.

.slider .tooltip{
    z-index: 1151 !important;
}

I would like to provide correct jsfiddle, but I am not able to find bootstrap-slider plugin cdn. Here is jsfiddle, which doesn't work because bootstrap-slider plugin source is missing.

jsfiddle

html

    <a href="#options" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<div id="options" class="modal hide fade">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Settings</h3>
  </div>
  <div class="modal-body">
      Vertex size <input id="nodeSize" data-slider-id='nodeSizeSlider' type="text" data-slider-min="1" data-slider-max="50" data-slider-step="1" data-slider-value="20"/><br><br>
      Edge size <input id="edgeSize" data-slider-id='edgeSizeSlider' type="text" data-slider-min="1" data-slider-max="50" data-slider-step="1" data-slider-value="20"/><br>
  </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
        <button class="btn btn-primary" id="saveSettings">Save</button>
      </div>
</div>

javascript

$(document).ready(function () { 
            $('#nodeSize').slider({
                    formatter: function(value) {
                            return value;
                    }
            });

            $('#edgeSize').slider({
                    formatter: function(value) {
                            return value;
                    }
            });
});

Solution

  • Add this to your Javascript:

    $("body").on("shown.bs.modal", function() {
        $("#edgeSize").slider('relayout');
        $("#nodeSize").slider('relayout');
    });
    

    Explanation: When modal is shown the function relayout is run on both input fields and renders the tooltip again after initialization.

    Source: https://github.com/seiyria/bootstrap-slider#functions

    Updated JSfiddle: http://jsfiddle.net/0sryor13/3/