Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery UI Slider First Value String
    primarykey
    data
    text
    <p>I am attempting to make a small change to a working jQuery UI Slider so that the first value of the first slider displays 'All' to the user instead of '0'.</p> <p>I have tried changing the slider based on the example in this post <a href="https://stackoverflow.com/questions/11339601/jquery-ui-slider-with-string-values">Jquery ui slider with string values?</a> however I currently cannot get a working solution.</p> <p>My code looks like this at present:</p> <pre><code>&lt;script&gt; $(function() { $("#peopleSlider").slider({ min: 0, max: 10, value: 0, animate: true, slide: function(event, ui) { $( "#people" ).val( ui.value ); var top_value_str = ui.value&gt;=99 ? ui.value+'+' : ui.value; $("#peopleSlider .tab-note:first").text(top_value_str); } }); $("#yearSlider").slider({ min: 2013, max: 2015, value: 2013, animate: true, slide: function(event, ui) { $( "#year" ).val( ui.value ); var top_year_str = ui.value&gt;=2099 ? ui.value+'+' : ui.value; $("#yearSlider .tab-note:first").text(top_year_str); } }); $('.ui-slider-horizontal .ui-slider-handle').append('&lt;span class="tab-note"&gt;&lt;/span&gt;').mousedown(function(e) { e.preventDefault(); }); $( "#people" ).val( $( "#peopleSlider" ).slider( "value" ) ); $( "#year" ).val( $( "#yearSlider" ).slider( "value" ) ); // Set default values - for sale var for_sale_init_bed_slide_val = $("#peopleSlider").slider("value"); var for_sale_top_value_str = for_sale_init_bed_slide_val&gt;=99 ? for_sale_init_bed_slide_val+'+' : for_sale_init_bed_slide_val; $("#peopleSlider .tab-note:first").text(for_sale_top_value_str); var for_sale_init_year_slide_val = $("#yearSlider").slider("value"); var for_sale_top_year_str = for_sale_init_year_slide_val&gt;=2099 ? for_sale_init_year_slide_val+'+' : for_sale_init_year_slide_val; $("#yearSlider .tab-note:first").text(for_sale_top_year_str); }); </code></pre> <p></p> <p>I want to change the min value for the #peopleSlider to show 'All' instead of '0'. I added var steps:</p> <pre><code> var steps = [ "All", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" ]; </code></pre> <p>But am not entirely sure how/where to add the 'steps' functions into the slider script?</p> <p>--</p> <p>WORKING SOLUTION</p> <pre><code>$("#peopleSlider").slider({ min: 0, max: 10, value: 0, animate: true, slide: function(event, ui) { $( "#people" ).val( ui.value ); var top_value_str = ui.value &gt;= 99 ? ui.value +'+' : ui.value; if(top_value_str &lt; 1) { //div of text that is being displayed $("#peopleSlider .tab-note").text("Any"); } else { //div of text that is being displayed $("#peopleSlider .tab-note").text(top_value_str); } } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload