So I have a form with an input and textarea field. I want @blur to launch a vue-method, but not if you press the tab-key to go to the next field, or if you click on the other field.
<form>
// stop @blur from triggering on
// 1) pressing tab key while in either one of the fields
// 2) clicking on the other field when one was focussed
<textarea @blur="blurOnEdit(item)" ></textarea>
<input @blur="blurOnEdit(item)" />
</form>
@jekinney I'm sorry to explain it poorly! I just want to launch a function when blurring the focussed input field. So when I click anywhere on the page outside of the input field, I'd want to launch a method.
This is easy when it comes to 1 input field: just add a @blur="method" to the html, but it's very hard when it comes to two input fields, and you need to not launch @blur when pressing immediately in the other input field, or when tabbing between the two input fields.
I hope this gives some more clarification! I do not need validation.
@jekinney Sorry! poor explanation again! I do not want to check for what's inside the input, empty is fine as well! I just need to check if the fields loose focus or not!
The reason is because I want to send ajax request and hide the input fields after clicking anywhere outside the fields. That's why I used blur. But I need it to wait with doing so when the place I click is in the other field, or I swap input fields with the tab key!
@jekinney I think the confusion comes from my jQuery selector. Please notice the :focus.length. I'm checking if the field is focussed, not if it contains characters.