matfish2 / vue-formular

a comprehensive vue.js form component
https://www.npmjs.com/package/vue-formular
MIT License
43 stars 11 forks source link

Add autofocus / focus event #3

Closed asmaps closed 8 years ago

asmaps commented 8 years ago

It would be nice to have a possibility to trigger focus() on a field after instantiating/showing it.

For example: Either through a autofocus property that triggers this.field.focus() on ready or somehow expose the field or the focus function so I can trigger the focus() event from the component in which I'm using the vf-field.

asmaps commented 8 years ago

Hacky workaround if sbdy needs this before there is an "official" feature:

<vf-text :value="internalValue" name="val" v-el:input></vf-text>
ready () {
  this.$els.input.getElementsByTagName('input')[0].focus()
}