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

    Can I use modals with input parameters?

    Help
    3
    6
    2200
    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.
    • J
      JDrechsler last edited by

      Hey guys,

      I have a list of bills and via click event I want to open a modal allowing me to edit the clicked bill. I could just do something like this:

      <q-item v-for="(bill, index) in bills">
          <q-item-side @click="clickedBill=bill;$refs.modalEditBill.open()"></q-item-side>
      </q-item>
      

      Then in my modal I could access clickedBill. Is it possible to do something like that instead?

      <q-item v-for="(bill, index) in bills">
          <q-item-side @click=$refs.modalEditBill(bill).open()"></q-item-side>
      </q-item>
      

      This way I do not need the clickedBill variable.

      Thank you in advance!

      Johannes

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

        Hello Johannes,

        Try this: $refs.modalEditBill.open(clickedBill = bill)
        Hope this is what you needed!

        Eleina

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

          Hi Eleina,

          I tried it using:

          <q-item v-for="(bill, index) in bills">
              <q-item-side @click=$refs.modalEditBill.open(clickedBill = bill)"></q-item-side>
          </q-item>
          

          and then in my modal I want to use the variable ‘clickedBill’

          <q-modal ref="modalEditBill">
              <div>Test {{clickedBill.title}}</div>
              <q-btn color="negative" class="pull-left" @click="$refs.modalEditBill.close()">Close</q-btn>
          </q-modal>
          

          That does not work without declaring that variable clickedBill before. I get the warning:

          [Vue warn]: Property or method “clickedBill” is not defined on the instance but referenced during render.

          I just want to pass bill or index (<q-item v-for="(bill, index) in bills">) to the modal I am opening. Do you know if that is possible?

          Thank you

          Johannes

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

            @JDrechsler
            Did you declare the clickedBill in the data () method of Vue? Like this:

            export default { 
                data () {
                    return: {
                        clickedBill: ''
                    }
                }
            }
            

            What you’re trying to do should be possible, because I have the same kind of code in my application.
            Hope it helps!

            Eleina

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

              Hi Eleina,

              if I do that then it works yes. Before I used a dialog like this:
              v-for=“biller in billers”
              button -> @click="showEditDialog(biller)

              showEditDialog(biller: Biller) {
              		Dialog.create({
              			title: biller.title,
              			form: {
              				title: {
              					type: 'text',
              					label: 'name',
              					model: biller.title
              				},
              				amount: {
              					type: 'number',
              					label: 'amount',
              					model: biller.amount,
              					min: 0,
              					max: 9999
              				},
                                .....
              

              Billers is an array that is declared in the data() method of Vue.
              There was no need to have a variable like clicked or selectedBiller. Is it possible to do the same with a modal? Open it and at the same time passing the biller and index from the for loop?

              Thank you

              Johannes

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

                @JDrechsler Did you end up finding a solution for your last question about passing the biller and index?

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