On Aug 10, 2006, at 2:37 PM, Thomas Hervé wrote: > you can't set the position of an element with display:none.
That did it. Thank you. The now working example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html> <head> <style> .positioned_invisible { visibility: hidden; } </style> <script type='text/javascript' src='MochiKit/MochiKit.js'></script> <script type='text/javascript' src='MochiKit/New.js'></script> <script type='text/javascript' src='MochiKit/Signal.js'></script> <script type='text/javascript' src='MochiKit/DragAndDrop.js'></script> <script type='text/javascript'> connect(window, 'onload', function() { connect('container',"onmousedown",my_mouse_down); new Draggable($('existing_div')); } ); function my_mouse_down(event) { log("=============================================="); var rpos = getElementPosition(event.mouse().page, $('container')); var d = DIV({'style':"background-color:#F00;top:"+rpos.y +"px;left:"+rpos.x+"px;height:20px;width: 20px;position:absolute",'class':'positioned_invisible'}); appendChildNodes('container', d); var z = new Draggable(d, {starteffect:function(element) { removeElementClass(element, 'positioned_invisible'); }, }); z.initDrag(event); return false; } </script> </head> <body> <div id="container" style="top:50px;left:50px;height:300px;width: 300px;border:1px solid black;position:relative"> <div id="existing_div" style="background-color:#0F0;top:10px;left: 10px;height:20px;width:20px"></div> </div> </body> </html> On Aug 10, 2006, at 2:37 PM, Thomas Hervé wrote: > > Some comments: > > - Don't use display: none in your css class, use visibility: hidden > instead. You have to do this because you can't set the position of an > element with display:none. > - Don't use window.onload with MochiKit. Use addLoadEvent, or better > connect(window, 'onload'). > - I think event.mouse().page is better suited to what you want to do > - After a few tests, it seems you may have to set some positions to > absolute to prevent some side effects. > > Good luck :) > > -- > Thomas > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit -~----------~----~----~----~------~----~------~--~---
