bootstrap-switch
bootstrap-switch copied to clipboard
Use with VueJS and other frameworks besides Angular
I see there is an integration for Angular but I was wondering if it is possible to get this working with VueJS? The problem is that when I add a v-bind attribute to my checkbox it gets removed when bootstrap-switch does it's thing.
I solved how to use it... I created a directive.
Vue.directive('bsswitch', {
twoWay: true,
bind: function () {
$(this.el).on("switchChange.bootstrapSwitch", function(e) {
this.set($(this.el).is(':checked'));
}.bind(this));
},
update: function(nv, ov) {
$(this.el).bootstrapSwitch('state', nv, true);
}
});
+1 👍