[mochikit] Re: Dragging DIV and positioning

2006-06-15 Thread Beau Hartshorne

On 14-Jun-06, at 3:18 PM, david wrote:

 I'm working with the Drag  Drop example on the website, using the
 draggable.js script. I've got a function on my page that creates new
 DIV elements and then connects them to the Draggable functions so that
 the user can move them around the page.

 Everything works great to this point.

 The problem is that when I create the new DIV elements (using  
 createDOM
 or standard Javascript functions), they are created and placed on a
 (seemingly) random position on the page.

 I want all new elements to start at position 0,0. Unfortunately,  
 when I
 create the element and place it at 0,0, the dragging no longer  
 works. I
 have tried explicitly setting the style.top/left properties on the new
 element as well as the setElementPosition() function. Both of these
 methods break the drag-ability of the new element.

 I'm guessing it is because the following is set on the element:
 style=top:0; left:0 which overrides the function in draggable.js
 which sets the location of the element. So I tried clearing the
 style.top and style.left properties of the element (after moving it to
 0,0), but this moved the new element back to its initial starting
 point.

 Here's an code snippet:

 //Get reference to form
 var f = $(form1);

 //Create new DIV to hold text
 var textElement = createDOM(DIV);
 textElement.id=element_ + m_ElementCount;
 textElement.className=draggable red text;

 //Add text element to form
 f.appendChild(textElement);

 //Move element to 0,0
 setElementPosition(textElement,{x:0, y:0});

 //Make text element draggable
 connect(textElement, 'onmousedown', Drag.start);

David, could you please post a complete example (with HTML)?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---



[mochikit] Re: Dragging DIV and positioning

2006-06-15 Thread david

Sorry, but it appears that this does work correctly. After posting my
original message, I continued to work on my page. At some point in my
development, I corrected something on my page which was conflicting
with the drag/drop after setting the location. The page now works
correctly. I worked backwards through my recent code but could not
identify exactly what was causing the problem.

Sorry for the trouble.
David Burgett


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
MochiKit group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~--~~~~--~~--~--~---