jquery - Conditional "step" for JQueryUI Slider -
i want give conditional steps jquery ui slider. if current selected value below 1951, take steps of 10 else take step of 1. want because limitation of dataset, have data 1900,1910 till 1950 , 1951,1952 on every year...
how can change based on year value? there way?
below current code
$( function() { $( "#slider-vertical" ).slider({ orientation: "vertical", range: "min", min: 1900, max: 2015, step: 1, slide: function( event, ui ) { $( "#selected_year" ).val( ui.value ); } }); $( "#selected_year" ).val( $( "#slider-vertical" ).slider( "value" ) ); } );
try modify step value of slider in change event handler:
$( "#slider" ).slider({ //... change: function( event, ui ) { var step = $(this).slider( "option", "step" ); var newstep = step; if (ui.value < 1951) { newstep = 10; } else { newstep = 1; } if (newstep != step) { $(this).slider( "option", "step", newstep ); } } });
Comments
Post a Comment