Skip to content

Instantly share code, notes, and snippets.

@denysxftr
Created May 12, 2015 13:44
Show Gist options
  • Save denysxftr/d8f037b93035fb4be4a6 to your computer and use it in GitHub Desktop.
Save denysxftr/d8f037b93035fb4be4a6 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