Skip to content

Instantly share code, notes, and snippets.

@logaretm
Last active May 3, 2017 11:43
Show Gist options
  • Save logaretm/13f9f0fa1df5b1ecf1e5 to your computer and use it in GitHub Desktop.
Save logaretm/13f9f0fa1df5b1ecf1e5 to your computer and use it in GitHub Desktop.
VueJS Utility Directives: some useful VueJS directives.
// Cleans GET query parameters by disabling empty inputs using jquery.
Vue.directive('clean', {
onSubmit() {
$(':input', this).each(function() {
this.disabled = !($(this).val());
});
},
bind() {
$(this.el).submit(this.onSubmit);
},
unbind() {
$(this.el).unbind('submit', this.onSubmit)
}
});
@rmNyro
Copy link

rmNyro commented May 2, 2017

Don't use that. Avoid using jQuery as much as you can. That's my advice.
Plus, those doesn't seem useful to me as it can be easily done (and in a lot of better ways) by VueJs directly into the html.
Please don't rush code, it'll do nothing good for you nor the others (especially the others who don't know).
I hope you won't be mad at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment