Skip to content

Instantly share code, notes, and snippets.

@tai2
Last active September 11, 2021 11:30
Show Gist options
  • Save tai2/6364c3f6e73fea9550fd4fd01a253b85 to your computer and use it in GitHub Desktop.
Save tai2/6364c3f6e73fea9550fd4fd01a253b85 to your computer and use it in GitHub Desktop.
jquery ui select menu vue component
Vue.component('jquery-selectmenu', {
props: ['value'],
template: `<select><slot /></select>`,
mounted: function() {
const emit = value => this.$emit('input', value);
$(this.$el).selectmenu({
change: function(event, data) {
emit(data.item.value);
}
});
$(this.$el).val(this.value).selectmenu('refresh');
},
watch: {
value: function (value) {
$(this.$el).val(value).selectmenu('refresh');
},
},
});
@idRem
Copy link

idRem commented Jul 4, 2019

Want to thank so much!!! Works like a charm! Big fat LIKE!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment