[Vuejs]-Medium Editor not pre-filling value in VueJS directive

4👍

Yes, a bind on the container will happen before the binding of its contents. You can wait for it by using nextTick.

Vue.directive('wysiwyg', {
  bind() {
    Vue.nextTick(() => new MediumEditor(this.el));
  }
});

new Vue({
  el: 'body',
  data: {
    value: 'Initial text'
  }
});
<script src="//cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/medium-editor/5.22.0/js/medium-editor.min.js"></script>
<link href="//cdnjs.cloudflare.com/ajax/libs/medium-editor/5.22.0/css/medium-editor.min.css" rel="stylesheet" />
<textarea v-wysiwyg name="{{ name }}" class="wysiwyg">{{ value }}</textarea>
👤Roy J

Leave a comment