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

    Click event on List and Icon

    Help
    3
    7
    6763
    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.
    • digiproduct
      digiproduct last edited by

      I have a QList with QItems, and in each QItem there are several QIcons.

      I placed click handlers on all the QIcons, and on the QItem. The intention being that clicking on an item calls specific functions, and clicking on the other part of the QItem calls a different function.

      It works … EXCEPT … clicking on a QIcon also causes the QItem click to trigger.

      How can I stop the click event being also passed to the QItem when the QIcon is clicked?

      1 Reply Last reply Reply Quote 0
      • P
        priya2995 last edited by

        Can you post your code to understand what did u do @digiproduct

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

          It’s slightly more involved than the following because there’s multiple icons, so this is not the complete code … but effectively if I click on the icon, or text in the list (which are both at the left) I want to call one function … and if I click on the profile icon which is on the right side of the list I want to call a different function …

          At present, clicking on the QIcon triggers both “showProfile” and “listActivity” but clicking on the QAvatar or QItemSection triggers only “listActivity”

          ‘’’

                <q-list bordered>
                  <q-item
                    v-for="contact in contacts"
                    :key="contact.id"
                    class="q-my-sm"
                    clickable
                    v-ripple
                    @click="listActivity"
                  >
                    <q-item-section avatar>
                      <q-avatar size="5em">
                        <img :src="contact.user_avatar">
                      </q-avatar>
                    </q-item-section>
          
                    <q-item-section>
                      <q-item-label>
                        {{ contact.full_name }} ({{ contact.email }})
                        <q-badge align="middle" color="green" v-if="contact.newcontact === 'true'">New</q-badge>
                      </q-item-label>
                      <q-item-label caption lines="1"></q-item-label>
                      <q-item-label caption lines="1">Next Appointment: {{ contact.next_contact_date }}</q-item-label>
                      <q-item-label
                        caption
                        lines="2"
                      >Last contact: {{ contact.last_contact_date }} {{ contact.lastcontactdescription }}</q-item-label>
                    </q-item-section>
          
                    <q-item-section side>
                      <q-icon
                        name="far fa-user"
                        color="grey"
                        size="2.5rem"
                        class="q-pa-lg"
                        @click="showProfile"
                      >
                        <q-tooltip>Full details for {{ contact.full_name }}</q-tooltip>
                      </q-icon>
          
          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by

            @digiproduct try putting an event modifier on your @click like so @click.prevent https://vuejs.org/v2/guide/events.html#Event-Modifiers.

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

              @metalsadman Thanks for that …

              StopPropogation is what I need, but I’ll read all that document carefully to ensure I do it in the best possible way, and use the correct modifier.

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

                @metalsadman PERFECT …

                All I had to do was change @click=“showProfile” to @click.stop=“showProfile” and it worked exactly as I need.

                Thanks for your help.

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

                  @digiproduct yeah in your case it’s the event on your inner element bubbling up to its parent @click.stop="showProfile" one should do it i think.

                  edit. nvm, you beat me to it haha, glad to help 🙂

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