Created
February 25, 2025 14:15
-
-
Save propertyhive/235efaefc722ef4af2a6d0c89bb23d79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() { | |
// Wait for the sliders to initialize | |
setTimeout(function() { | |
jQuery(".search-form-slider-bedrooms_slider").each(function() { | |
var slider = jQuery(this); | |
var label = slider.closest("form").find(".search-form-slider-value-bedrooms_slider"); | |
// Hook into the slide event to modify the values | |
slider.slider("option", "slide", function(event, ui) { | |
var minVal = ui.values[0]; | |
var maxVal = ui.values[1]; | |
// Format the displayed value | |
var displayMax = (maxVal === 5) ? "5+" : maxVal; | |
// Ensure we correctly replace the entire label | |
label.text(minVal + " - " + displayMax); | |
// Update the hidden input values | |
slider.closest("form").find(".min_slider_value-bedrooms_slider").val(minVal); | |
slider.closest("form").find(".max_slider_value-bedrooms_slider").val((maxVal === 5) ? 99 : maxVal); | |
}); | |
// Trigger the change to update the label on load | |
var initialValues = slider.slider("values"); | |
var initMin = initialValues[0]; | |
var initMax = (initialValues[1] === 5) ? "5+" : initialValues[1]; | |
label.text(initMin + " - " + initMax); | |
slider.closest("form").find(".max_slider_value-bedrooms_slider") | |
.val((initialValues[1] === 5) ? 99 : initialValues[1]); | |
}); | |
}, 500); // Delay to allow plugin initialization | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment