Skip to content

Instantly share code, notes, and snippets.

@lordspace
Created February 16, 2014 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lordspace/9030169 to your computer and use it in GitHub Desktop.
Save lordspace/9030169 to your computer and use it in GitHub Desktop.
How to which slider has been dragged in a range slider of jQuery UI using it in WordPress plugin
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core ' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_register_style('my_jq_ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery.ui.all.css', __FILE__, false);
wp_enqueue_style('my_jq_ui');
<div id="slider-range"></div>
jQuery( "#slider-range" ).slider({
range: true,
step: 25000,
//min: jQuery( "#min_budget" ).val(),
max: 5000000, // 5m
values: [ 0, 1000000 ],
slide: function( event, ui ) {
var min = jQuery( "#min_budget" ).val() || 0;
var max = jQuery( "#max_budget" ).val() || 0;
// if the ui.value equals one of the values we'll find out which was dragged.
if (ui.value == ui.values[0]) {
jQuery( "#min_budget" ).val( ui.values[ 0 ] );
} else if (ui.value == ui.values[1]) {
jQuery( "#max_budget" ).val( ui.values[ 1 ] );
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment