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
    1. Home
    2. muffin_mclay
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 4
    • Best 1
    • Groups 0

    muffin_mclay

    @muffin_mclay

    1
    Reputation
    1
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    muffin_mclay Follow

    Best posts made by muffin_mclay

    • RE: Pass object as property to a template looses reactivity

      @olaf You are almost there. I suggest that you use the v-model pattern for what you want to accomplish

      <treats-named-editor :value=selectedTreat  v-model=selectedTreat   />
      

      In your component do this

      <template>
        <q-card-section class="q-gutter-sm">
          <div class="text-h6">Object in props</div>
          <q-input outlined :value="local.name" @input="$emit('input', local)" label="Name"/>
          <q-input outlined :value="local.calories" @input="$emit('input', local)" label="Calories"
          />
        </q-card-section>
      </template>
      
      <script>
      export default {
        props: {
          treat: Object
       },
        created () {
           this.local = this.treat // we can't change **treat** so we assign it to a new variable
        },
        data () {
           return {
               local: null
          }
       }
      }
      </script>
      
      posted in Help
      M
      muffin_mclay

    Latest posts made by muffin_mclay

    • RE: Pass object as property to a template looses reactivity

      @olaf I have moved the handler to a method

      <template>
        <q-card-section class="q-gutter-sm">
          <div class="text-h6">Object in props</div>
          <div class="text-h6">This is not fully reactive any more</div>
          <q-input outlined :value="local.name" @input="onLocalValueChange" label="Name"/>
          <q-input outlined :value="local.calories" @input="onLocalValueChange" label="Calories"/>
        </q-card-section>
      </template>
      
      <script>
      export default {
        props: {
          treat: Object
        },
        created() {
          this.local = this.treat // we can't change **treat** so we assign it to a new variable
        },
        data() {
          return {
            local: null
          }
        },
        methods: {
          onLocalValueChange()
          {
            this.$emit('input', this.local)
          }
        }
        
      }
      </script>
      
      

      Forgot: Yes I saw the codesandbox and saved my changes there as well

      posted in Help
      M
      muffin_mclay
    • RE: Pass object as property to a template looses reactivity

      @Hawkeye64 Yes you are right. I usually take props’ values and do something with them and assign the result to a local value. I guess it is just a habit now lol

      posted in Help
      M
      muffin_mclay
    • RE: Pass object as property to a template looses reactivity

      @olaf You are almost there. I suggest that you use the v-model pattern for what you want to accomplish

      <treats-named-editor :value=selectedTreat  v-model=selectedTreat   />
      

      In your component do this

      <template>
        <q-card-section class="q-gutter-sm">
          <div class="text-h6">Object in props</div>
          <q-input outlined :value="local.name" @input="$emit('input', local)" label="Name"/>
          <q-input outlined :value="local.calories" @input="$emit('input', local)" label="Calories"
          />
        </q-card-section>
      </template>
      
      <script>
      export default {
        props: {
          treat: Object
       },
        created () {
           this.local = this.treat // we can't change **treat** so we assign it to a new variable
        },
        data () {
           return {
               local: null
          }
       }
      }
      </script>
      
      posted in Help
      M
      muffin_mclay