We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New feature request: How about add some hooks to 'v-on' directive, such as 'before' and 'after'.
What I want to do: I want to add a some validate before click event being triggered, and lots of button not to be validated before click.
How it works: If I have the before hook, I need to run the 'before method' and only the method return true I will do the real event binding.
The text was updated successfully, but these errors were encountered:
How I handle this at the moment:
... methods: { someButtonClickHandler () { new Promise( (resolve, reject) => { // setup logic }) .then( (result) => { // before logic, }) .then( (result) => { // the handler }) .catch( (err) => { // handle exceptions }) .finally( () => { // cleanup ? }) } } ...
Might not be the right way, but that's how I'm dealing with your use case.
specifically:
import store from 'application/store'; import {storeAnswer} from 'application/store/actions'; import validate from 'validate.js'; export default { vuex: { storeAnswer }, computed: { firstName: { get () { return store.state.Thing.firstName; }, set (value) { validate.async(data, constraints) .then( () => { this.storeAnswer(value); }); .catch((err)=>{ // handle validation errors ? }); } } } };
Sorry, something went wrong.
You can simply do it inside the handler. If you need to reuse the same logic, you can either make that a filter or just compose it inside JS:
function guard (handler) { return function (e) { if (...) { e.preventDefault() } return handler.call(this, e) } } methods: { onClick: guard(function (e) { // ... }) }
@yyx990803 All right, I guess I get your point, THX a lot
No branches or pull requests
New feature request:
How about add some hooks to 'v-on' directive, such as 'before' and 'after'.
What I want to do:
I want to add a some validate before click event being triggered, and lots of button not to be validated before click.
How it works:
If I have the before hook, I need to run the 'before method' and only the method return true I will do the real event binding.
The text was updated successfully, but these errors were encountered: