单击Algolia IntSantSearch文本中的关键字时,请发送过滤的请求



我正在使用Algolia即时搜索一个项目,但是我有一个小问题来发送过滤的请求。这里是我想做的示例,使用即时搜索示例之一:https://community.algolia.com/instantsearch.js/examples/e-commerce/

在此页面上,旁边有所有过滤器,主要内容块中的产品。在产品描述中,我想在关键字上有链接,这些链接可作为过滤器运行。例如,对于斩波板" agitim"(左侧的第一个产品),在说明中,有关键字" white"。我想,如果此关键字是一个链接,则在单击它时,它可以按单击颜色选择器中的白色值进行操作。

我尝试使用jQuery触发函数,并且它运行良好,但仅适用于实际上显示在过滤器中的值。按照我的示例,白色值是可以的(因为颜色拾取器中有一个可用),但它不能与黄色值一起使用。

有人有一个想法解决这个问题吗?

最好,

您可以做的是直接使用类似的algoliasearch-helper:

// bind the click event on the color name, then
$('.hits .color').click(function(ev) {
  var color = $(this).data('color'); // given you store the color somehwere in a data-color attribute
  search.helper.toggleRefinement('color', color); // search is your instantsearch instance
  search.helper.search();
});

这是一个非常好的用户酶,我们将在上面编写完整的指南。让我知道这个答案是否已经是您问题的好开始。

最新更新