Can't add container dynamically
Antoine553 opened this issue · 0 comments
Antoine553 commented
Hello, i tried to make a container with elements to copy to other containers generated by jquery when i click on a button. So my button that add containers use the function addPhase() as follow.
I looked up many similar problems and tried many different variance of this code (i knwo your not supposed to add left several time) but can't manage to understand how to add my new containers. This version work for the first div generated but not the others (i tried adding only them but don't work either).
`
var initphase = 1;
function addPhase(){
$(".scenarioLayout").append('<div id="right-copy-'+initphase+'tomany" class="container scenarioDiv ng-scope" style="min-width: 100px;min-height: 100px;">');
console.log('right-copy-'+initphase+'tomany');
if (initphase == 1) {
dragula([document.getElementById('left-copy-1tomany'), document.getElementById('right-copy-'+initphase+'tomany')], {
copy: function (el, source) {
return source === $('left-copy-1tomany');
},
accepts: function (el, target) {
miseenforme();
return target !== $('left-copy-1tomany');
}
});
}else{
dragula([document.getElementById('right-copy-'+initphase+'tomany')]);
}
initphase = initphase+1;
}
`
So how can i add my new 'right-copy-'+initphase+'tomany' containers every time pls ?