Skip to content

Instantly share code, notes, and snippets.

@Galadirith
Forked from denysxftr/v-jquery-change.js
Created March 22, 2017 19:48
Show Gist options
  • Save Galadirith/aa6eb624cd9e0abf59ce29505ac8f60d to your computer and use it in GitHub Desktop.
Save Galadirith/aa6eb624cd9e0abf59ce29505ac8f60d 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