Skip to content

Instantly share code, notes, and snippets.

@vinayakkulkarni
Last active July 29, 2017 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinayakkulkarni/6f327afd2c3c8f2d7d970efcceb55350 to your computer and use it in GitHub Desktop.
Save vinayakkulkarni/6f327afd2c3c8f2d7d970efcceb55350 to your computer and use it in GitHub Desktop.
Vue + Semantic-UI Rating
Vue.component('rating', {
template: `<div class="ui star rating" :data-rating="value"></div>`,
props: ['value'],
watch: {
value: function (val, oldVal) {
if (val == null) {
$(this.$el).rating('clear rating');
}
}
},
mounted() {
let t = this;
$(this.$el).rating({
fireOnInit: true,
onRate(val) {
t.$emit('input', val);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment