EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jenn.bohm on May 23, 2012, 02:04:12 PM



Title: Trouble dragging to a canvas?
Post by: jenn.bohm on May 23, 2012, 02:04:12 PM
I'm not able to drop a cloned item onto a canvas. When I make the target element a div, it drops there just fine, and when I turn it into a canvas, the dropped item just disappears.

http://jsfiddle.net/fb8gt/1/

droppable is #wall


Title: Re: Trouble dragging to a canvas?
Post by: stworthy on May 28, 2012, 06:08:41 PM
When dragging an element to HTML5 canvas, the 'onDrop' can be triggered but you cannot add elements into canvas. Please rewrite the 'onDrop' code to draw some text on canvas:
Code:
$('.drop').droppable({
onDragEnter:function(){
$(this).addClass('over');
},
onDragLeave:function(){
$(this).removeClass('over');
},
onDrop:function(e,source){
var s = $(source).find('img').attr('title');  // get the source item text
var ctx = document.getElementById("wall").getContext("2d");
ctx.fillText(s, 10, 10);
}
 });


Title: Re: Trouble dragging to a canvas?
Post by: jenn.bohm on June 01, 2012, 07:06:00 AM
Thanks for your help. I thought it was going to be something like that, and it looks like canvas will not work for our application. Fortunately, I have now convinced those who decided to use a canvas of that fact. :)