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

    [SOLVED] How to emit q-select @input only on change

    Framework
    4
    8
    4808
    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.
    • dmitry.polushkin
      dmitry.polushkin last edited by dmitry.polushkin

      Currently, if you use select @input it receives a value even if I click on the same option in the select which is currently selected. How I find with @input event that the select has changed it’s value?

      1 Reply Last reply Reply Quote 0
      • J
        jraez last edited by

        I’m not sure if it’s doable but you can put a watch on your model.
        In the watch, you’ll have the new value and the old value.

        watch: {
            myModel (newValue, oldValue) {
                if (newValue != oldValue) {
                   // value changed.
                }    
            }
          }
        
        dmitry.polushkin 1 Reply Last reply Reply Quote 0
        • Shoooryuken
          Shoooryuken last edited by

          https://forum.quasar-framework.org/topic/2923/solved-q-select-on-change-event-not-triggered/5 ?

          dmitry.polushkin 1 Reply Last reply Reply Quote 0
          • dmitry.polushkin
            dmitry.polushkin @jraez last edited by

            @jraez
            Thanks for the one of the solutions, but it doesn’t work in my case.
            While I’m going to use watch value will be already changed. And because I’m passing this value into a parent component via @emit that not what I want. Would be great to have more clear solution.

            1 Reply Last reply Reply Quote 0
            • dmitry.polushkin
              dmitry.polushkin @Shoooryuken last edited by

              @Shoooryuken
              There are no such event @change for q-select anymore since around v1.0. I’ve looked into the q-select sourcecode, but haven’t found any possible solution to do that easily. Might be I’ve looked in the wrong direction.

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

                You can save the initial value in data when your child component is mounted. Then in @input check if the value is different than initial.

                1 Reply Last reply Reply Quote 1
                • metalsadman
                  metalsadman @dmitry.polushkin last edited by

                  @dmitry-polushkin use lazy input, ie’ :value="model"... @input="doSomething".

                  1 Reply Last reply Reply Quote 0
                  • dmitry.polushkin
                    dmitry.polushkin last edited by

                    @metalsadman thanks, that solved my issue. Really forgot the idea behind the v-model.

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