Git Product home page Git Product logo

Comments (5)

atinux avatar atinux commented on August 28, 2024 1

Then you need to add a method onSearch to update q and call fetch() again

from content.

atinux avatar atinux commented on August 28, 2024

@sajjadalis your Header us emitting q event, then you can listen in you index.vue and call $fetch, see more on https://vuejs.org/v2/guide/components.html#Emitting-a-Value-With-an-Event

<Header ... @q="$fetch" />

from content.

sajjadalis avatar sajjadalis commented on August 28, 2024

@atinux Thanks for reply.

I tried this but its not working.

With only @q="$fetch", input field does not accept text, when i try to type it goes blank.
<Header :q="q" @q="$fetch" />

If i use @q="q = $event.target.value, $fetch" then input and v-model works fine but doesn't filter content.

<Header :q="q" @q="q = $event.target.value, $fetch" />

from content.

sajjadalis avatar sajjadalis commented on August 28, 2024

@atinux Thanks for the help.

Is this the correct way to call onSearch method? It's working and filtering content, but i'm not sure if its require to call the whole await this.$content again.

methods: {
    async onSearch($event) {
      this.q = $event.target.value;

      this.posts = await this.$content('posts')
      .search(this.q)
      .fetch()
  }
}

from content.

atinux avatar atinux commented on August 28, 2024

I think that you can call this.$fetch() instead of this.$content('posts')..

from content.

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.