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

    Problems with q-input

    Framework
    2
    4
    1215
    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.
    • D
      davidhalsted last edited by

      Hello, I am having an odd problem with entering currency amounts using q-input. Setting type to number and :decimals to 2 works great on its own. I also have a function to add up the results as they come in. If the user tries to enter a decimal point with the function running, the decimal point gets wiped out. This only happens if I try to add the results on @input. If I don’t add them up, the component works as expected (but then I don’t get my running total). Any ideas?

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

        Perhaps some snippets from your code might help. 🙂

        1 Reply Last reply Reply Quote 0
        • D
          davidhalsted last edited by Shone

          Fair enough!

          In a v-for that loops over the lines of the report once it is loaded:

          <q-input v-model="reportLine.sales_total" float-label='Sales' type="number" :decimals="2" align="right" @input="calcTotalMobile"/>

          The report is loaded via a call to a Web service in created().

          Code:

          export default {
             data () {
                return report: {},
            },
           methods: {
              calcTotalMobile: function () {
                    let daysale = 0
                   for (let i = 0; i < this.report.reportLines.length; i++) {
                      daysale += this.report.reportLines[i].sales_total
                    }
                    this.report.weekly_sales_total = daysale
              }
           }
          }
          

          If I comment out the line

          this.report.weekly_sales_total = daysale

          q-input accepts decimals, but not if it is active.

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

            I haven’t looked into the Quasar code for this, but if it’s passthough to the input tag, maybe it’s passing the decimals to the step parameter. if so, then it needs to read as decimals="0.01" - not sure if this will work for you but worth a try.

            Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

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