- This topic is empty.
August 21, 2014 at 12:38 am #180078
I want to drag elements from datalist and drop them in a div.
when you drag an element you must draw a line from it to some point.
using asp.net and jqueryAugust 21, 2014 at 12:41 am #180079
Why MUST you use asp.net?August 21, 2014 at 12:48 am #180080
sorry HTML not asp.netAugust 21, 2014 at 1:02 am #180082
Ha ha ha. I get them confused all the time myself :)
jQuery makes it pretty easy to create drag and drop elements. Could you try creating a Codepen so we can help?August 21, 2014 at 1:15 am #180083
plz check this:
i need that when i drop an element to draw a line from it , and when drop another
element to automatically connected to the drawn line.
could you help me?August 21, 2014 at 1:16 am #180085August 21, 2014 at 1:18 am #180086
Well, first of all, your elements aren’t draggable yet. Let’s forget about the line for now.
See here:August 21, 2014 at 1:34 am #180088August 21, 2014 at 1:40 am #180089
I’m not able to drag the numbers. I assume that’s what’s supposed to be happening.August 21, 2014 at 1:47 am #180091
i have tried it on a stand alone application and it works fine.
may be the jquery library.
anyway when drop an item how to draw a line from that element
and automatically connected to seconde dropped element and so on.
could you help please?August 21, 2014 at 1:58 am #180093
Look into something like this:
You need to get the position of each element with a function that’s called every time you move anything. But… that’s a shipload of state management. Also… I’m not really sure how you should go about drawing the lines.
Typically, you’d use canvas for something like this. But… it looks like you’re trying to do some straight up DOM action. I would recommend this:
In theory, you should be able to pass your coordinates to some function that handles the drawing of these svg lines.
Hey, is there any way you could make this your Gravatar:August 22, 2014 at 1:07 am #180216
Snap.svg also makes things draggable. It’s pretty damn easy.August 22, 2014 at 8:42 am #180272
Thank you so much NIX.
but i need an example if possible to draw a line between draggable elements.
i see the library JsPlumb, but i didnt know how to start.August 25, 2014 at 9:27 am #180532
The first thing you need to be able to do is drag something and
console.log()the new position. As long as you’re able to somehow return the new position… you should be able to re-draw the line as it moves.
Now, AFAIK… this is NOT a trivial task. It may or may not work with SVG… I haven’t tried. It could surely work with canvas. But… canvas does have some limitations as far as I’m concerned.June 16, 2015 at 7:01 am #203829