Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$("#slider_range").slider is not a function

Ok, I have included the google api libraries for Jquery UI, like so:

<script type='text/javascript'  src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js' ></script>

Now I have a script that updates some spans and a hidden input on document slide and not only, on document ready:

<script type="text/javascript">
            $(document).ready(function()
            {
                 var slider=$('#slider_range').slider({
                        range:true,
                        min:0,
                        max:5,
                        step:1,
                        values:[0,3],
                        slide:function(event,ui)
                        {
                          $('#level').val(ui.values[0]+'-'+ui.values[1]);
                          $('#low').html(ui.values[0]);
                          $('#high').html(ui.values[1]);
                        }
                 });

                 var s=slider;
                 if(s.slider("values",0)==s.slider("values",1))
                 {
                    $('#level').val(s.slider("values",0));
                    $('#low').html(s.slider("values",0));
                    $('#high').html(s.slider("values",0));
                 }
                 else
                     {
                       $('#level').val(s.slider("values",0)+'-'+s.slider("values",1));
                       $('#low').html(s.slider("values",0));
                       $('#high').html(s.slider("values",1));
                     }
              });
         </script>

The ideea is that on a page it shows the slider and on another not. The error message I get from Firebug is this:

$("#slider_range").slider is not a function

And points to the line

slide:function(event,ui)

What could be causing this? Why on a page the slider can be seen and on another (which uses the same template that loads the above) can`t?

Please help!

like image 539
Gabriel Avatar asked Sep 27 '11 09:09

Gabriel


2 Answers

There were two differing jquery libraries included on the second page.

like image 85
Gabriel Avatar answered Nov 05 '22 00:11

Gabriel


I just had the same error while i used the foundation framework from zurb along with jquery ui slider.

Problem #1: the foundation framework 3.2.4 already delivers jquery 1.8.1 and i tried to include my own copy of jquery 1.9 just before the foundation files. (= duplicate jquery inclusion)

Problem #2: the order of my inclusions. jquery ui needs to be included AFTER the foundation framework files.

like image 22
patrics Avatar answered Nov 05 '22 00:11

patrics