Slide 20
Slide 20 text
10 . 1
VUE DIRECTIVES
Custom directives provide a mechanism for mapping data changes to arbitrary DOM behaviour
"seiyria‐bootstrap‐slider": "7.0.3"
Vue.directive('slider', {
bind: function(){ /* do preparation work */
var vm = this.vm;
var key = this.expression;
var slider = $(this.el).slider()
.on('change', function(ev){ vm.$set(key, ev.value.newValue); })
.data('slider');
},
update: function(val){ /* do something based on initial/updated value */
val = parseFloat(val);
if(!isNaN(val)){ $(this.el).slider('setValue', val); }
},
unbind: function(){ /* do clean up work */ },
});