jQuery ui Drag&Drop in mouse position -


I have managed to drag and drop an object into the div container , however, The object is always placed in the left corner. I would like to know how I can keep the object where the user has a cursor pointer.

Can be seen in the problem.

I understand that the solution may be the following part of the code:

  $ clone. RemoveClass ('label-item') .removeClass ('UI-draggable' ) .addClass ('dragIt'). Css ('height', 'auto'). CSS ('width', 'auto');  

and I must add left and top terms according to ui.offset .

Solve.

  var positionX = Ui.offset.left - $ container.offset () left; Var position Y = ui.offset.top - $ container.offset () Top; $ Clone.css ('left', positionX + 'px'). Css ('top', positionY + 'px');  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -