Clear all filters in form which contains a range
Hi,
I'm wondering if you can help please?
I've got some filters set up, and one of them is a range slider, based on the example here: https://demos.kunkalabs.com/mixitup/filtering-by-range/
The filters are working great, and the range is working well too. However, I'm trying to add a 'Clear Filters' button and getting some unexpected behaviour. The first click on the button clears the form, and other 'conventional' filters just fine, but the custom range values persist. Then when the button is clicked a second time, the range values are cleared out.
I've looked through the documentation and cannot find where the hooks are documented. My current line of thought is that the custom filter that is being registered doesn't actually get cleared when the form is reset.
Any ideas at all?
I'm having the same issue. The reset event does not trigger a change event on input range, that could start a new operation that runs the testResultEvaluateHideShow that could take the new range value into account.
Here is a quick and ugly workaround : https://codepen.io/ZalemCitizen/pen/NWzRKgK
for whatever reason (the real one, in fact) a simple change event dispatch on one of the range inputs is not a sufficient workaround
you have to reset each input range yourself like
inputRange.value = inputRange.defaultValue
then trigger a new mixItUp operation (i.e dispatch a single input range change event)
If you're using mixItUp MultiFilter, the reset event on form will trigger a new mixItUp operation too early and since change event handler on range input is running this :
mixer.filter(mixer.getState().activeFilter)
the current mixer state still contains values of other fields before reset, so it restores these former values
I suggest you
- remove change event dispatch
- change your button type from
resettobutton - on click event handler on this button, you reset the input ranges to their default values
- run form reset to reset all other filters : mixItUp reset event handler on form will then refilter