Moin List, Is there a "simple" way for moving DOM nodes and insert them into another DOM part ? Example: Moving a DIV into another DIV. I''m actually using prototype Insertion to manage to do this but this solution doesn''t satisfies me. Regards FJ --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 19, 8:10 pm, Frederic JECKER <f.jec...-Q24KPKXrcE4YLvoOxY5KjA@public.gmane.org> wrote:> Moin List, > > Is there a "simple" way for moving DOM nodes and insert them into > another DOM part ? > Example: Moving a DIV into another DIV. > I''m actually using prototype Insertion to manage to do this but this > solution doesn''t satisfies me.Assign the node you want to move as a child of the node you want to make it a child of, e.g. <input type="button" value="Move option" onclick=" $(''A'').appendChild($(''B'').options[0]); "> <select id="A"> <option>A 1 <option>A 2 </select> <select id="B"> <option>B 1 <option>B 2 </select> -- Rob --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, After further working/searching I found a solution, below an example: var tomove=$(div); if(tomove.parentNode!=null && tomove.parentNode.id!=''glassPane''){ var clone=tomove.cloneNode(true); $(''glassPane'').appendChild(clone); var objBody = document.getElementsByTagName(''body'').item(0); objBody.removeChild(tomove); } RobG a écrit : On Sep 19, 8:10 pm, Frederic JECKER wrote: Moin List, Is there a "simple" way for moving DOM nodes and insert them into another DOM part ? Example: Moving a DIV into another DIV. I''m actually using prototype Insertion to manage to do this but this solution doesn''t satisfies me. Assign the node you want to move as a child of the node you want to make it a child of, e.g. A 1 A 2 B 1 B 2 -- Rob -- Frédéric JECKER GIP Sym@ris Pavillon 1 27 rue du 4ème RSM B.P. 29 F-68250 ROUFFACH Tél : +33 (0)3 89 78 79 02 Fax : +33 (0)3 89 78 79 00 Courriel : f.jecker-Y0KRaRJ5EAdBDgjK7y7TUQ@public.gmane.org Web : http://www.symaris.com PFaites un geste pour l''environnement - avez vous réellement besoin d''imprimer ce courriel ? PPlease consider the environment - do you really need to print this email ? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 19, 10:20 pm, Frederic JECKER <f.jec...-Q24KPKXrcE4YLvoOxY5KjA@public.gmane.org> wrote:> Hi, > After further working/searching I found a solution, below an example:But it''s not as good as the "solution" I offered. :-)> > var tomove=$(div); > if(tomove.parentNode!=null && tomove.parentNode.id!=''glassPane''){ > var clone=tomove.cloneNode(true); > $(''glassPane'').appendChild(clone); > var objBody = document.getElementsByTagName(''body'').item(0); > objBody.removeChild(tomove);There is no need to clone the node, add the clone, then remove the original. Just move the node to where you want it: $(''glassPane'').appendChild(tomove); That''s it. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 20, 7:19 am, RobG <rg...-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> On Sep 19, 10:20 pm, Frederic JECKER <f.jec...-Q24KPKXrcE4YLvoOxY5KjA@public.gmane.org> wrote: > > > Hi, > > After further working/searching I found a solution, below an example: > > But it''s not as good as the "solution" I offered. :-) > > > > > var tomove=$(div); > > if(tomove.parentNode!=null && tomove.parentNode.id!=''glassPane''){Thinking about that a little further, there is not much value in the first test - the only element that doesn''t have a parentNode is the document, which can''t be retrieved by $(someId). Consider: var tomove = $(div); var target = $(''glassPane''); if (tomove.parentNode != target) target.appendChild(tomove); -- Rob --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---