-
-
Save Galadirith/aa6eb624cd9e0abf59ce29505ac8f60d to your computer and use it in GitHub Desktop.
custom vue js directive for jquery events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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