This example doesn't really use any of prototype's functionality beyond the $
function, but it is still small enoguht. The first 3 lines are just setup
lines, the last two specifically deal with attaching the elements to the DOM. I
believe there is a function that will reproduce the 2nd to last line as a
function call, but for the life of me I can't remember what it is named. Either
way, typing out the actual code is just as fast (if not faster).
-
- var outerDiv = document.createElement( "DIV" );
- outerDiv.id = "foo";
- var innerDiv = $("stuff");
-
- innerDiv.parentNode.appendChild(outerDiv);
- outerDiv.appendChild( innerDiv );
-Andrew Martinez
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] Behalf Of
Michael Peters
Sent: Thursday, November 09, 2006 11:18 AM
To: Prototype/Scriptaculous
Subject: [Rails-spinoffs] creating a wrapper div
I'm trying to find the cleanest way to do the following:
I want to have a class that takes a div's id as the argument and then creates
another div to wrap around the first, without changing anything about the
original div.
<div id="stuff"></div>
new Foo('stuff')
would result in
<div id="foo"><div id="stuff></div></div>
I'm looking at the Insertion classes, but there doesn't seem to be an
Insertion.Around, and the best thing I can come up with is to create the new
wrapper div, initially empty, then copy the target div and insert it as the
first child and then delete the target div. This seems messy and potentially
complicated if I have to eval any JS or un-register any JS handlers in the
original div. I'd like my class to know as little about the original div as
possible.
Thanks.
--
Michael Peters
Developer
Plus Three, LP
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---