vuejs / Discussion

Vue.js discussion
167 stars 17 forks source link

How to add v-model dynamically created html? #490

Open 6pm opened 8 years ago

6pm commented 8 years ago

I use vue.js. I want add vue model in selector, who created using jquery plugin. My code:

`div class="app" div class="wysiwyg-wrap" /div

new Vue({
    el: '.app',
    data: {
        wysiwygText: 'text demo'
    },
    created: function(){
        $('.wysiwyg-wrap').trumbowyg();
    }
});

`

Jquery plugin trumbowyg create inside '.wysiwyg-wrap' many html elements. How to add in one of this elements v-model binding? I want type in my redactor and save result in 'wysiwygText' from vue model. Thank you for any answers!

simplesmiler commented 8 years ago

This is not the way to do it. Instead you should:

  1. Watch the viewmodel and update state of the plugin.
  2. Listen for the events the plugin emits and update viewmodel.

К слову, есть русскоязычный чат, где можно получить помощь быстрее.