Hello,
To filter results, I have created several facets on 1 views page.
I have checkbox type facets, and 2 range-slider type facets. If I use the range-slider facets, the other facets are reinitialized.
Other point, if I use a checkbox facet, the range-slider facet isn't updated with the results.
When we use range-slider facet, can I keep the active items of the other facets?
Thanks for your help.
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | ajax_facets_range_widget-3012531-38.patch | 5.25 KB | chanderbhushan |
| #38 | ajax_facets_range_widget-3012531-37.patch | 4.88 KB | renrhaf |
| #38 | ajax_facets_range_widget-3012531-37--with-render-fix.patch | 5.97 KB | renrhaf |
Comments
Comment #2
kumkum29 commentedI have found why I get this problem. In views, the ajax option was enabled. So, the facet of range-slider type don't work correctly.
It's boring because don't refresh the page is more friendly, we keep the results and only the results are changed.
For the moment, I disable this option. I see in several posts similar problems with this ajax option and the facets...
Comment #3
kumkum29 commentedComment #4
oxyc commentedPatch which adds Ajax Facets support.
Comment #5
oxyc commentedComment #6
kumkum29 commentedHi Oxyc,
after having installed your patch, I see that we have 2 problems with range slider widget :
1- Range slider reload the page
2- Range slider don't keep the active facets
Your patch resolve the first problem. When we change the slider the page isn't reloaded. Nice !
But, the second problem is always existent. When we change the value of the range slider, the URL is rebuilt with only the slider facet. The others facets are reinitialized, e.g. :
Thanks.
Comment #7
oxyc commentedThanks for the review!
The issue is that the FacetBlockAjaxController disregards all JS settings by using `renderPlain` rather than `render`. I'm not sure why it doesnt just use render.
In my case it seems to work by just switching it. Unfortuantely I hit another issue where my Views DOM ID didn't match so I applied https://www.drupal.org/project/facets/issues/3013795 which fixed. My own patch now depends on that one.
Another issue I ran into was that the facet filtering is lost when you filter using Views Exposed Filters which I also fixed for my own use case.
I'm currently running low on time so I dont have time to split these fixes across all the different issues therefore this patch is not mergable at the moment (as it depends on another patch). Once I have some spare time I can look into it again but if someone else works on it this should be a good start.
Comment #8
oxyc commentedComment #9
mfbPatch(es) worked for us, thanks oxyc.
Comment #10
alphawebgroup@oxyc
Hi
I'm sorry, but #7 patch is not applicable anymore...
Comment #11
geek-merlinLooks like this code is quite parallel to other issues. It would be good to consolidate and join forces.
Comment #12
sofiene.chaariThis patch allows to solve the problem of an ajax facet in a search page and does not include a facet range widget, we are not obliged to apply an additional patch, it is based on the patch https:// www.drupal.org/files/issues/2018-11-16/ajax_facets_range_widget-3012531-...
Comment #13
akalam commentedI tried to re-roll the patch #7 against the latest dev release and the range facets still not use ajax.
#12 instead, worked for me and solved the problem (now the range slider facets use ajax).
Applying the patch on https://www.drupal.org/project/facets/issues/3052574 has no effect on the range widgets with ajax.
Comment #14
akalam commentedThe patch #12 makes sliders work with ajax, but is reseting other filters. Here is a patch fixing it. Basically it gets the current request and merge the query params within the new proposed url. I now the code is ugly and there is a mostly duplicated loop but it works as starting point and maybe it can be improved by someone else.
Comment #15
akalam commentedThe previous patch appends again and again the slider parameter to the url instead of replacing the existing one. Here is a improved version solving this issue.
Comment #16
akalam commentedThe previous patch was wrong, this is the good one.
Comment #17
akalam commentedComment #18
yivanov commentedIs there a way to trigger range sldier facet with AJAX from other places like this?
$(this).trigger('facets_filter', [ $(this).val() ]);Comment #19
akalam commented@yivanov The event name is "slidestop". See https://api.jqueryui.com/slider/#event-stop
Comment #20
yivanov commentedHi, @akalam, I managed to do it like this
Comment #21
vadim478 commentedThe patch #16 is working almost perfectly but in my case I have 2 Range Slider facets on the same page. When I update the first one, the second is not updated.
Any fix for this issue ?
I have also the issue with other facets type. If I change one facets, the Range Slider facets are not updated
UPDATE :
So after some test, I applied the patch in #16 + replace all renderPlain by render in /src/Controller/FacetBlockAjaxController.php
And It's working now.
The patch in #22
Comment #22
vadim478 commentedThank's to akalam and oxyc
Comment #23
kiseleva.t commentedI've faced with js error when using a non-range slider and value provided instead of values.
Created 2 patches, one from #16 and one from #21, because I have the fix #21 from patch #3052574: Facets with AJAX not working in most of situations.
Comment #24
kiseleva.t commentedSorry, the previously provided patches applied incorrectly in js, corrected.
Comment #25
trickfun commentedPatch 24 doesn't work. I have this js error:
Uncaught TypeError: settings.facets.sliders[facetId].urls is undefinedPatch 21 works.
Comment #26
kiseleva.t commentedAdded fix for error from comment #25.
Comment #27
trickfun commentedNow it works.
thank
Comment #28
renrhafThank you so much all of you for these wonderful patches !
Unfortunately, patch from #26 does not work for facets with source using a specific "filter_key" (different than the hardcoded "f" value in the patch). Here is a new one supporting this feature.
Please note that the patch only works flawlessly on my side using the patch with the render fix.
Comment #29
renrhafComment #30
trickfun commentedPatch #28 works.
thank
Comment #31
karlsheaI merged the work from #28 (with render fix) into the work at #3052574: Facets with AJAX not working in most of situations because the two conflict with each other. Should the work on this issue continue over there?
Comment #32
itzikas commented#31 works for me. Thank you.
Comment #33
joey91133 commentedfix #28 range slider not support multi field in same time
Comment #34
joey91133 commented#43 have missing some code.
Comment #35
joey91133 commentedfix #28 range slider not support multi field in same time.
this patch base on #28
Comment #36
webdrips commentedIn order to be considered accessible, range sliders need part of a form with a label: https://www.a11ywithlindsey.com/blog/creating-accessible-range-slider-css
Comment #37
renrhafRerolled patch from #28 for version 2.0.6.
I did not include any changes from #33, #34, #35 as it seemed to be related to some other bug and not relevant here.
Thank you.
Comment #38
renrhafComment #39
pcambraThis works great to make the slider ajaxify.
Comment #40
pcambraSorry for the noise, I was testing patches and found out that #3013795: Robustify how ajax finds the facet block is already fixing this one, so I would suggest to deprecate this patch in favor of the linked one, as it covers more ground.
Comment #41
chanderbhushan commentedUpdated patch. When you are applying a range slider filter without any other filter its add a base URL to filter values