Sunday 15 January 2012

javascript - How to set min/max interval and values for jQuery UI slider? -



javascript - How to set min/max interval and values for jQuery UI slider? -

i jave problem jquery ui slider.

i have function "pricer()" , arguments give it:

1)min_price, max_price - interval range ( min_price-------------max_price )

2)start_price, end_price - subinterval ( min price----start_price--------end_price-----max_price )

code:

function pricer(min_price, max_price, start_price, end_price) { $( "#slider_price" ).slider({ range: true, min: min_price, step:10, max: max_price, values: [start_price, end_price ], slide: function( event, ui ) { $('#price1').val(ui.values[0]); $('#price2').val(ui.values[1]); } }); $('#price1').change(function () { $('#slider_price').slider("values",0, $(this).val()); }); $('#price2').change( function() { $('#slider_price').slider("values",1,$(this).val()); }); $('#price1').val($('#slider_price').slider("values",0)); $('#price2').val($('#slider_price').slider("values",1)); };

i phone call function twice in order:

1) on document.ready event. ( pricer(4, 536, 4, 536); )

2) when should set new values slider. ( pricer(4, 536, 11, 12) )

and wrong interval:

$('#slider_price').slider('values', 0)

and

$('#slider_price').slider('values', 1)

returns me value '14' , '14'.

i debug , found happend when set values property in object send slider().

i didn't found open bug reports in jquery ui slider. may misunderstanding of jquery ui slider work?

it has fact set step 10. since range starts 4 next closest value 11 , 12 14.

slider widget api doc step states that:

(step) determines size or amount of each interval or step slider takes between min , max. total specified value range of slider (max - min) should evenly divisible step.

javascript jquery

No comments:

Post a Comment