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.

CommentFileSizeAuthor
#41 ajax_facets_range_widget-3012531-38.patch5.25 KBchanderbhushan
#38 ajax_facets_range_widget-3012531-37.patch4.88 KBrenrhaf
#38 ajax_facets_range_widget-3012531-37--with-render-fix.patch5.97 KBrenrhaf
#35 ajax_facets_range_widget-3012531-35--with-render-fix.patch902 bytesjoey91133
#34 ajax_facets_range_widget-3012531-34--with-render-fix.patch6.4 KBjoey91133
#33 ajax_facets_range_widget-3012531-33--with-render-fix.patch4.54 KBjoey91133
#28 interdiff-26-28.txt3.03 KBrenrhaf
#28 ajax_facets_range_widget-3012531-28--with-render-fix.patch6.06 KBrenrhaf
#28 ajax_facets_range_widget-3012531-28.patch4.98 KBrenrhaf
#26 ajax_facets_range_widget-3012531-26--with-render-fix.patch4.5 KBkiseleva.t
#26 ajax_facets_range_widget-3012531-26.patch3.42 KBkiseleva.t
#24 diff_21_24.txt955 byteskiseleva.t
#24 diff_16_24.txt1.28 KBkiseleva.t
#24 ajax_facets_range_widget-3012531-24--with-render-fix.patch4.46 KBkiseleva.t
#24 ajax_facets_range_widget-3012531-24.patch3.38 KBkiseleva.t
#23 diff_21_23.txt1.54 KBkiseleva.t
#23 diff_16_23.txt1.89 KBkiseleva.t
#23 ajax_facets_range_widget-3012531-23--with-render-fix.patch3.85 KBkiseleva.t
#23 ajax_facets_range_widget-3012531-23.patch2.77 KBkiseleva.t
#22 ajax_facets_range_widget-3012531-21.patch4.03 KBvadim478
#16 facets-3012531-16.patch3.36 KBakalam
#15 facets-3012531-15.patch64 bytesakalam
#14 facets-3012531-14.patch3.12 KBakalam
#12 fix-slider-ajax-facet.patch1.34 KBsofiene.chaari
#7 range-slider.patch2.62 KBoxyc
#4 ajax_facets_range_widget-3012531-4.patch1.06 KBoxyc

Comments

kumkum29 created an issue. See original summary.

kumkum29’s picture

I 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...

kumkum29’s picture

Title: Range slider reinitialize the other facets » Range slider (and slider) refresh the page and reinitialize the other facets
oxyc’s picture

Title: Range slider (and slider) refresh the page and reinitialize the other facets » Ajax Facets do not support Range Slider
Category: Support request » Bug report
StatusFileSize
new1.06 KB

Patch which adds Ajax Facets support.

oxyc’s picture

Status: Active » Needs review
kumkum29’s picture

Hi 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. :

// Initial facets
mysite.com/productsf%5B1%5D=price%3A%28min%3A0%2Cmax%3A40000%29&f%5B1%5D=type%3A170079
// We change the range slider
mysite.com/productsf%5B1%5D=price%3A%28min%3A0%2Cmax%3A50000%29

Thanks.

oxyc’s picture

StatusFileSize
new2.62 KB

Thanks 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.

oxyc’s picture

Status: Needs review » Needs work
mfb’s picture

Patch(es) worked for us, thanks oxyc.

alphawebgroup’s picture

@oxyc
Hi
I'm sorry, but #7 patch is not applicable anymore...

geek-merlin’s picture

Looks like this code is quite parallel to other issues. It would be good to consolidate and join forces.

sofiene.chaari’s picture

StatusFileSize
new1.34 KB

This 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-...

akalam’s picture

I 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.

akalam’s picture

StatusFileSize
new3.12 KB

The 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.

akalam’s picture

Status: Needs work » Needs review
StatusFileSize
new64 bytes

The 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.

akalam’s picture

StatusFileSize
new3.36 KB

The previous patch was wrong, this is the good one.

akalam’s picture

yivanov’s picture

Is there a way to trigger range sldier facet with AJAX from other places like this?

$(this).trigger('facets_filter', [ $(this).val() ]);

akalam’s picture

@yivanov The event name is "slidestop". See https://api.jqueryui.com/slider/#event-stop

yivanov’s picture

Hi, @akalam, I managed to do it like this

            $(facet).slider('values', [min,max]);
            $(facet).slider('option', 'stop')(null, { values: [min,max]});
vadim478’s picture

The 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

vadim478’s picture

StatusFileSize
new4.03 KB

Thank's to akalam and oxyc

kiseleva.t’s picture

I'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.

kiseleva.t’s picture

StatusFileSize
new3.38 KB
new4.46 KB
new1.28 KB
new955 bytes

Sorry, the previously provided patches applied incorrectly in js, corrected.

trickfun’s picture

Patch 24 doesn't work. I have this js error:

Uncaught TypeError: settings.facets.sliders[facetId].urls is undefined

Patch 21 works.

kiseleva.t’s picture

Added fix for error from comment #25.

trickfun’s picture

Now it works.
thank

renrhaf’s picture

Thank 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.

renrhaf’s picture

Status: Needs work » Needs review
trickfun’s picture

Patch #28 works.
thank

karlshea’s picture

I 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?

itzikas’s picture

#31 works for me. Thank you.

joey91133’s picture

fix #28 range slider not support multi field in same time

joey91133’s picture

StatusFileSize
new6.4 KB

#43 have missing some code.

joey91133’s picture

StatusFileSize
new902 bytes

fix #28 range slider not support multi field in same time.
this patch base on #28

webdrips’s picture

In 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

renrhaf’s picture

Version: 8.x-1.1 » 2.0.6

Rerolled 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.

renrhaf’s picture

pcambra’s picture

Version: 2.0.6 » 2.0.x-dev
Status: Needs review » Reviewed & tested by the community

This works great to make the slider ajaxify.

pcambra’s picture

Status: Reviewed & tested by the community » Needs review

Sorry 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.

chanderbhushan’s picture

StatusFileSize
new5.25 KB

Updated patch. When you are applying a range slider filter without any other filter its add a base URL to filter values