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

    [V1] [Solved] Form submits twice

    Help
    2
    6
    347
    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.
    • M
      mKomo last edited by mKomo

      Hi all.

      I’m using the following component (I’ve removed all unnecessary parts)

      The issue is when ENTER is pressed in the input field, the form submits twice.

      I’ve fixed the issue by removing the form element completely and just having inputfields and buttons but this seems a bit crude.

      <template>
        <q-form
          @submit="onSubmit"
          autofocus
          >
      
      
         <q-input
          v-model="form.field"
          placeholder="Invitation Code"
          />
      
         <q-btn
          label="Submit"
          type="submit"
          color="primary"
         />
      
        </q-form>
      </template>
      
      <script>
      export default {
        data() {
          return {
            form: {
              field: '',
            }
          };
        },
        methods: {
          onSubmit() {
            console.log(this.form.field)
          }
        }
      };
      
      </script>
      

      Theres probably something obvious I’m missing but thanks in advance in any case.

      Edit:
      -Typos

      Solution

      Update from beta .14 to .16

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Is your problem solved? I can’t reproduce it.

        https://codepen.io/smolinari/pen/JVydVm

        Scott

        M 1 Reply Last reply Reply Quote 0
        • M
          mKomo @s.molinari last edited by

          @s-molinari Unfortunately not I think the problem lies somewhere else in my codebase.

          Possibly poor namespacing etc.

          In any case the error doesn’t lie with the component itself. I’ll investigate further and post the solution in my case if its solved

          1 Reply Last reply Reply Quote 0
          • M
            mKomo last edited by

            So digging into it further, remove type="submit" from the q-btn seems to fix the issue, I’ve got no idea why so ill keep looking into it

            1 Reply Last reply Reply Quote 0
            • M
              mKomo last edited by mKomo

              Ok so I updated from beta .14 to .16 everythings fine even with type="submit"

              Copied from release notes:

              fix(QBtn): [v1] Submit on form with “enter” generates 2 requests #3812

              1 Reply Last reply Reply Quote 1
              • s.molinari
                s.molinari last edited by

                Yes, when reporting bugs or asking if there is a possible bug here, it’s always best to have your Quasar up-to-date, before you report it. Thanks!

                Scott

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