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

    Extending the QSlider with an up and down button.

    Help
    1
    2
    236
    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

      I’m trying to extend the QSlider with an up and down button.
      So, let’s call this new component: btn-slider.
      This new component has following markup:

      <div>
            <q-btn 
              @click="down()" 
              size="md" 
              round 
              icon="remove">
            </q-btn>
          <q-slider ref='slider'
          v-bind="$attrs" v-on="$listeners"
          />
          <q-btn 
            @click="up()" 
            size="md" 
            :disable='disable()' 
            round 
            icon="add">
          </q-btn>
        </div>
      

      As you can see, I bind all props/events to the QSlider:

      <q-slider ref='slider'
          v-bind="$attrs" v-on="$listeners"
          />
      

      By doing so, all props are passed directly to the QSlider:

      <div id="q-app">
        <div class="q-pa-md">
            <q-badge color="secondary">
              Model: {{ value }}
            </q-badge>
        
            <btn-slider
              v-model="value"
              :min="0"
              :max="20"
              :step="1"
              label label-always
              color="light-green"
            ></btn-slider>
          </div>
      </div>
      

      Now, the problem is that I can’t find a decent way to update the value of the QSlider when the up down button is triggered.

      Please find here a codepen: https://codepen.io/paulbladel/pen/KJYPwG

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

        ok, answered my own question : https://codepen.io/paulbladel/pen/KJYPwG
        the trick is to use the sync modifier.

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