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

    Set q-search `suffix` attribute dynamically

    Framework
    4
    9
    552
    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.
    • T
      toymachiner62 last edited by toymachiner62

      How can I set the q-search suffix attribute dynamically? like calling a computed function or something?

      This is what i’m trying to achieve 0_1540333656821_de729a1c-4573-4b00-b216-d54a7d464c44-image.png

      This is the code I have
      <q-search v-model="terms" placeholder="Search" :after="[{icon: 'fal fa-times', content: true, handler: clearSearch}]" suffix="numberOfResults" hide-underline class="no-border" />

      And this is what it’s producing
      0_1540333741382_15394fbd-a9ac-4aa2-ba71-e875ffdde86d-image.png

      You can see that suffix="numberOfResults" is producing the literal string numberOfResults rather than calling a function

      1 Reply Last reply Reply Quote 0
      • rstoenescu
        rstoenescu Admin last edited by

        :suffix="numberOfResults"

        1 Reply Last reply Reply Quote 1
        • Hawkeye64
          Hawkeye64 last edited by

          Yes, don’t forget to bind :suffix so it’s treated as javascript.

          1 Reply Last reply Reply Quote 0
          • T
            toymachiner62 last edited by toymachiner62

            Doesn’t work.

            <q-search v-model="terms" placeholder="Search" :suffix="numberOfResults" hide-underline class="no-border" />
            
            ...
            methods: {
                numberOfResults () {
                  console.log('here')
                }
            }
            ...
            

            produces:
            0_1540486224091_4a558073-a096-4aae-a9b8-8feddd2d06fe-image.png

            1 Reply Last reply Reply Quote 0
            • metalsadman
              metalsadman last edited by metalsadman

              @toymachiner62
              try :suffix="`{numberOfResults()}`" or use a computed property, note that suffix only accepts a string.

              1 Reply Last reply Reply Quote 0
              • T
                toymachiner62 last edited by

                :suffix="{numberOfResults()}"

                Produces this error
                0_1540488958628_e17528fa-32a5-4a4e-8c86-5ed151ac89c2-image.png

                1 Reply Last reply Reply Quote 0
                • T
                  toymachiner62 last edited by

                  But this works!

                  :suffix="numberOfResults()"

                  1 Reply Last reply Reply Quote 0
                  • metalsadman
                    metalsadman last edited by

                    weird, maybe it does accept a function, although docs says String.

                    1 Reply Last reply Reply Quote 0
                    • Hawkeye64
                      Hawkeye64 last edited by

                      if the function is in methods, add parenthesis to it: :suffix="numberOfResults()", if the function is computed, then it’s treated like a value, not a function, therefore do not add parenthesis to it: :suffix="numberOfResults"

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