Skip to content

Instantly share code, notes, and snippets.

@ricardov03
Last active August 9, 2022 09:32
Show Gist options
  • Select an option

  • Save ricardov03/65b9fa73ce005a9c9363dae6d10cd6f0 to your computer and use it in GitHub Desktop.

Select an option

Save ricardov03/65b9fa73ce005a9c9363dae6d10cd6f0 to your computer and use it in GitHub Desktop.
This is how to create a custom call to the submit event of a form from another element.
<script setup>
import { ref } from 'vue'
// The variable name should match the ref's name in the template.
const newForm = ref(null)
const submitForm = () => {
// We need the value to access the element.
newForm.value.submit()
}
</script>
<template>
<form ref="newForm">
<a @click="submitForm">Someter</a>
</form>
</template>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment