-
Notifications
You must be signed in to change notification settings - Fork 3
jQuery rangeslider defaults and options
Maikel Bos edited this page Dec 28, 2020
·
3 revisions
The jQuery-rangeslider is created with ease of use in mind. All options can be configured using data-attributes. However, sometimes there is a need to override the options explicitly or influence the default behaviour. This is possible both by changing the default options, and by explicitly passing the options when first creating the rangeslider.
All defaults and options are defined as functions to make them as flexible as possible.
<div id="example-slider">
</div>
<script type="text/javascript">
// Override the default to look at a different data-attribute
$.fn.rangeslider.defaults.getStepSize = function(element) {
return $(element).data('value-increase');
}
// For this specific rangeslider, explicitly set the field name
$('#example-slider').rangeslider({
getFieldName: function(element) {
return 'example';
}
});
</script>
Below are all options that you can provide your own implementation of.
-
getRangeStart(element)
should return the start value of the range slider; any integer value is valid -
getStepCount(element)
should return the number of steps in the range slider; any positive integer value is valid -
getStepSize(element)
should return the value increase of each step in the range slider; any positive integer value is valid -
getValue(element)
should return the starting value of the range slider; any integer value is valid but it will be converted to confirm to a valid step on initializing the slider -
getFieldName(element)
should return the field name of the hidden input field that is created for posting the value in a form -
getInputAttributes()
should return an object with html attributes to apply to the hidden input field -
getThumbAttributes()
should return an object with html attributes to apply to the thumb element -
getTrackAttributes()
should return an object with html attributes to apply to the track element