IsraelZablianov / draggable-vue-directive

Vue2 directive that handles drag & drop
MIT License
314 stars 50 forks source link

Not working on element created dynamically #6

Closed Kchin-project closed 6 years ago

Kchin-project commented 6 years ago

Hi, I'm trying to attach the directive to a dynamically created rect but is not working I'm trying this inside a method:

var xmlns = "http://www.w3.org/2000/svg"; var stage = document.createElementNS(xmlns, "rect"); stage.setAttributeNS(null, 'v-draggable', ''); stage.setAttributeNS(null, 'width', 350); stage.setAttributeNS(null, 'height', 80); stage.style.cssText = 'fill:#f2f2f2;stroke-width:1;stroke:rgb(0,0,0)'; console.log(stage) document.getElementById('canvas').appendChild(stage)

IsraelZablianov commented 6 years ago

You shouldn't use setAttrbute, even Vue directives won't work for you (e.g. v-if, v-on)

Please check : https://stackoverflow.com/questions/30546370/how-to-make-vue-js-directive-working-in-an-appended-html-element