No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    how to toggle the search bar with search button?

    Help
    3
    5
    482
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K
      kaizoku2508 last edited by

      I was try to make the search bar appear and disappear whenever I click the search button. This mean the button is toggle the search field. But I cannot make the search bar disappear after I click search button.

      <template>
        <q-input
          :hidden="showSearch"
          v-model="search"
          dark
          label-color="white"
          type="search"
          class="bg-primary"
          color="white" />
        <q-btn
          flat rounded
          icon="search"
          color="white"
          @click="toggleSearch"/>
      
      </template>
      
      <script>
      import { defineComponent, ref } from 'vue'
      
      export default defineComponent({
      
        setup () {
          const showSearch = ref(false)
          const search = ref('')
          const toggleSearch = () => {
            console.log('toggle search', showSearch.value)
            showSearch.value = !showSearch.value
          }
      
          return {
            search,
            showSearch,
            toggleSearch
          }
        }
      })
      </script>
      
      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @kaizoku2508 last edited by

        @kaizoku2508 said in how to toggle the search bar with search button?:

        showSearch

        use v-if <q-input v-if="showSearch"....

        K 1 Reply Last reply Reply Quote 0
        • K
          kaizoku2508 last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • K
            kaizoku2508 @metalsadman last edited by kaizoku2508

            @metalsadman i tried v-if nothing happen but when I change to v-show, it can toggle as I wanted. is it correct to use v-show. Anyway thanks for that idea

            dobbel 1 Reply Last reply Reply Quote 0
            • dobbel
              dobbel @kaizoku2508 last edited by

              @kaizoku2508

              is it correct to use v-show

              https://stackoverflow.com/questions/42419192/what-is-better-in-vue-js-2-use-v-if-or-v-show

              1 Reply Last reply Reply Quote 0
              • First post
                Last post