Search code examples
jquerytwitter-bootstrapbootstrap-slider

bootstrap-slider not initialized


I am trying to use the bootstrap slider from here: https://github.com/seiyria/bootstrap-slider. However I am not able to initialize the slider. My code snippet looks like this:

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="css/bootstrap-switch.min.css" rel="stylesheet"/>
    <link href="https://raw.githack.com/seiyria/bootstrap-slider/master/css/bootstrap-slider.css" rel="stylesheet" /> 
    <link rel='stylesheet' href='css/jquery-ui.css'>
    <link rel='stylesheet' href='css/ol.css'>
    <script src="js/jquery-ui.js"></script>
    <script src="http://openlayers.org/en/v3.9.0/build/ol.js"></script>
    <script src="js/jquery.ui.widget.js"></script>
    <script src="js/jquery.iframe-transport.js"></script>
    <script src="js/jquery.fileupload.js"></script>
    <script src="https://raw.githack.com/seiyria/bootstrap-slider/master/js/bootstrap-slider.js"></script>    
    <script src="js/bootstrap-switch.min.js"></script>

</head>

<body>
        <input style='width:80px;' class='opacity' type='text' value='' data-slider-min='0' data-slider-max='1' data-slider-step='0.1' data-slider-tooltip='hide'>

    <script type="text/javascript">
        $('input.opacity').slider();
    </script>

</body>

This gives me simple input type as shown in the figure

enter image description here

Then if I do:

$('input.opacity').bootstrapSlider();

This gives me error as:

enter image description here

What am I missing here?


Solution

  • please try

    $(function() {
        $('input.opacity').bootstrapSlider();
    });
    

    to execute code when document is ready.