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 handle both click on whole q-item as well as button inside

    Framework
    3
    4
    1725
    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.
    • P
      paul last edited by paul

      Following code will make that when clicking on the q-item always the code for moreButtonClick is executed and not showChild.
      How can I force that when the whole item is clicked showChild is executed and only when the more button is click the corresponding button event is raised?

       <q-list link v-for="currentItem in items" :key="currentItem.id">
                  <q-item tag="label"  @click="showChild()" >
                   <q-item-main >
                         <div> more stuff </div>
                    </q-item-main>
                    <q-item-side right>
                        <q-btn  @click="moreButtonClick(currentItem)" icon="more vert"> </q-btn>
                    </q-item-side>
                  </q-item>
      </q-list>
      
      1 Reply Last reply Reply Quote 0
      • C
        chbarr last edited by

        <div id="q-app">
          <div class="q-ma-md">
            <q-list link v-for="currentItem in items" :key="currentItem.id">
              <q-item tag="label" @click.native.prevent="showChild()" >
                <q-item-main >
                  <div> more stuff </div>
                </q-item-main>
                <q-item-side right>
                  <q-btn @click.capture.stop="moreButtonClick(currentItem)" icon="more vert"></q-btn>
                </q-item-side>
              </q-item>
            </q-list>
          </div>
        </div>
        

        In q-item native.prevent : preventDefault on the native Dom click event
        in q-item-side capture.stop : capture the event click and stop propagation

        1 Reply Last reply Reply Quote 2
        • P
          paul last edited by

          @chbarr thanks. Very much appreciated.

          1 Reply Last reply Reply Quote 0
          • D
            deadly last edited by

            This should be sticked! thanks!

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