I am trying to drag images onto the drop zone, then based on there data attribute append a div to the drop zone.
But at the moment its just appending the image and saying undefined is not a function. I then need to be able to drag the new divs around the drop zone
here is the html
<ul class="tab-list">
<li>
<img src="img/one.png" data-itemstate="rectangle" />
</li>
<li>
<img src="img/one.png" data-itemstate="circle" />
</li>
<li>
<img src="img/one.png" data-itemstate="triangle" />
</li>
</ul>
here is the js
$('.tab-list img').draggable({
helper: "clone",
});
$('#main').droppable({
drop:function(event, ui) {
var item = $(ui.draggable);
console.log(item.data('itemstate'));
if(item.data('itemstate') == 'triangle'){
var add = '<div class="triangle"></div>';
}
add.appendTo($(this));
}
});