Last active
February 8, 2017 21:40
-
-
Save hal0gen/514308c6583490e8c0856318f37442a3 to your computer and use it in GitHub Desktop.
Vue component with a Foundation Slider
This file contains hidden or 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
<template> | |
<div class="row"> | |
<div class="medium-10 medium-offset-1 columns"> | |
<h1>{{ msg }}</h1> | |
<div class="slider" data-slider v-bind:data-initial-start="this.dataValue" v-bind:data-end="this.dataEnd"> | |
<span class="slider-handle" data-slider-handle role="slider" tabindex="1"></span> | |
<span class="slider-fill" data-slider-fill></span> | |
<input type="hidden" class="slider-input"> | |
</div> | |
<p>Value: {{ dataValue }}</p> | |
</div> | |
</div> | |
</template> | |
<script> | |
export default { | |
mixins: [ | |
// eslint-disable-next-line | |
require('../mixins/foundation'), | |
], | |
name: 'slider', | |
data() { | |
return { | |
msg: 'Slider', | |
dataValue: 50, | |
dataEnd: 200, | |
}; | |
}, | |
mounted() { | |
// This is needed: https://github.com/vuejs/vue/issues/372 | |
$(this.$el).on('moved.zf.slider', () => { | |
this.dataValue = $('.slider-input').val(); | |
}); | |
}, | |
}; | |
</script> | |
<style lang="scss" scoped> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment