Created
May 12, 2015 13:44
-
-
Save denysxftr/d8f037b93035fb4be4a6 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