Git Product home page Git Product logo

Comments (6)

bidoubiwa avatar bidoubiwa commented on May 18, 2024 1

Hello @ThisIsMyFavouriteJar

You can map on all search results using transformItems. Here is the documentation about it.

In your case for example you could do something like:

<template>
  <!-- ... -->
  <ais-hits :transform-items="transformItems" />
</template>

In your methods field

transformItems(items) {
      const brands = items.find((item) => item.brand && item.brand.length > 0)
      if (brands.length > 0) {
        // hide your component
      }
      return items
    },

from meilisearch-vue.

ThisIsMyFavouriteJar avatar ThisIsMyFavouriteJar commented on May 18, 2024

Hi @bidoubiwa , thank you for your answer! Actually I tried this method, but somehow it appears that as soon as I change the necessary variables (e.g. this.showBrands) that Instantsearch automatically makes another request without any filters, thereby immediately negating the change to this.showBrands.

I guess my problem / question is now as follows: How to call a function in 'methods' (where instantMeiliSearch is defined in the data() ) without making another call to Meilisearch?

Hope my answer is clear, and appreciate your help!

from meilisearch-vue.

ThisIsMyFavouriteJar avatar ThisIsMyFavouriteJar commented on May 18, 2024

After some searching I found this:
https://stackoverflow.com/questions/57193330/updating-unrelated-vue-js-variable-causing-input-values-in-template-to-disappear

Turns out that Vue re-renders everything once a variable is updated, in my case causing all original inputs to disappear. Seems to me that this makes it rather hard to use transformItems to get the necessary values......

Edit: It seems the reason everything is rendering again has to do with the way I update my variables. Perhaps this is the way to go after all!

from meilisearch-vue.

bidoubiwa avatar bidoubiwa commented on May 18, 2024

Hello @ThisIsMyFavouriteJar

Did you manage to make it work ?

from meilisearch-vue.

ThisIsMyFavouriteJar avatar ThisIsMyFavouriteJar commented on May 18, 2024

Hi @bidoubiwa , unfortunately not yet. The problem seems to be that changing the variable to hide the filter title causes vue to rerender, resetting all search criteria.... Not sure if I am doing things wrong, or if this is just the nature of vue. If you managed to make this work in an earlier project of yours it would be great to hear how you did it!

from meilisearch-vue.

bidoubiwa avatar bidoubiwa commented on May 18, 2024

@ThisIsMyFavouriteJar

Is your code on an open repo? In case not could you share your instantSearch configuration through a gist?

from meilisearch-vue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.