Skip to content

Instantly share code, notes, and snippets.

@aloha1003
Forked from Galadirith/v-jquery-change.js
Created July 21, 2017 09:57
Show Gist options
  • Save aloha1003/df08138cc505e26cf72e63523790a5e5 to your computer and use it in GitHub Desktop.
Save aloha1003/df08138cc505e26cf72e63523790a5e5 to your computer and use it in GitHub Desktop.
custom vue js directive for jquery events
Vue.directive('jquery-change', {
twoWay: true,
bind: function() {
var self = this;
$(self.el).on('change', function() {
self.set(this.value);
});
},
update: function(data) {
if(data) {
$(this.el).val(data).trigger('change').trigger('keyup');
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment