Thats fantastic Christophe, thank you very much for your help. It all makes much more sense now, I'm going to go and have a play. I'll be sure to come back and let you know how I get on.
Once again thank you very much for taking the time out to help, you're a gent!! Many thanks Mark On Feb 20, 3:00 pm, Christophe Porteneuve <[EMAIL PROTECTED]> wrote: > Hey Mark, > > Mark a écrit : > > > window.onload=function() > > First, don't do that. Please :-) Use this: > > Event.observe(window, 'load', function() {...}); > > > variable. How would I apply the draggable call to the div when I'm > > creating it at run time? > > Right after you create those. OK, let's say I'm smack in your XML > parsing code. It probably goes something like this: > > // general loop over some XML nodeset -- n is the current node > var div = document.createElement('DIV'); > div.id = 'clipping_' + ....; > ... > someParentNode.appendChild(div); > // end of loop > > Am I right? > > Now, what you can do is this, right after appendChild: > > div._myDraggable = new Draggable(div, { ...options... }); > > That takes care of the creation time. > > Now, the code that strips existing DIVs from their container before > creating new ones in their stead could go like this: > > 1) Fetch the DIVs. If these are the only children of your container, > go like this: > > var divs = $('containerId').immediateDescendants(); > > If there are other things, but they have a specific class: > > var divs = $('containerId').getElementsByClassName('clipping'); > > If they only have their ID pattern to identify them, go like this: > > var divs = $('containerId').immediateDescendants().select( > function(div) { return div.id.startsWith('clipping_'); }); > > Now, you can deregister their draggables: > > divs.each(function(div) { div._myDraggable.destroy(); }); > > And you can remove them (either on the fly, in the callback function: > > divs.each(function(div) { div.remove()._myDraggable.destroy(); }); > > Or by clearing the container: > > $('containerId').update(''); > > However, you might want to split deregistration and removal, since the > fetch-and-destroy-draggable bit can be used for toggling dragging off, > as well. And symetric code can be used for toggling it on (reusing the > create-and-assign line described earlier). > > 'HTH > > -- > Christophe Porteneuve aka TDD > [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---