This is how I create the element:

var date = new Date(); var path = '/frontend/web/image/frontendImage/carusel/'+date.getFullYear()+'/'+(1+date.getMonth())+'/avatar-'+file.name; var img = document.createElement('img'); img.src = path; img.setAttribute('class','draggable ui-widget-content'); document.getElementById('forIMG').appendChild(img); 

then I try to connect draggable libraries in this way

 $(".draggable").draggable(); $("#forIMG").on('draggable','.draggable'); 

but neither option works. Do not tell me why?

  • five
    forImg and forIMG probably different things. Apparently so - Alexey Shimansky
  • Damn probably :) - Sergalas

2 answers 2

 var date = new Date(); var path = "http://a2.cdn.gaiaonline.com/dress-up/avatar/ava/c8/68/50f9be992a68c8_flip.png?t=1131021187_3.00_00" var img = document.createElement('img'); img.src = path; img.setAttribute('class', 'draggable ui-widget-content'); document.getElementById('forIMG').appendChild(img); $(".draggable").on('click', function() { alert('oй'); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="forIMG"></div> 

    Try to write like that

     $("#forImg .draggable").on('click',function () { alert('yes'); }); 

    • no, it does not work. - Sergalas