<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>leine.info &#187; Element</title>
	<atom:link href="http://leine.info/tag/element/feed/" rel="self" type="application/rss+xml" />
	<link>http://leine.info</link>
	<description>Discover my public and private World.</description>
	<lastBuildDate>Thu, 22 Dec 2011 13:57:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Prototype Insert, oder wie füge ich Elemente richtig ein</title>
		<link>http://leine.info/2009/01/prototype-insert-oder-wie-fuge-ich-elemente-richtig-ein/</link>
		<comments>http://leine.info/2009/01/prototype-insert-oder-wie-fuge-ich-elemente-richtig-ein/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 09:32:29 +0000</pubDate>
		<dc:creator>jleine</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Element]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://leine.info/?p=53</guid>
		<description><![CDATA[Neulich bin ich über ein triviales Problem gestoplert. Ich wollte eigentlich eine rechte simple DOM Manipulation mit Hilfe von Prototype realisieren. Doch leider hatte ich so meine Schwierigkeiten mit der Prototype Doku. Folgendes war meine Ausgangssituation: [code lang='xhtml'] Some navigation &#8230; <a href="http://leine.info/2009/01/prototype-insert-oder-wie-fuge-ich-elemente-richtig-ein/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Neulich bin ich über ein triviales Problem gestoplert. Ich wollte eigentlich eine rechte simple DOM Manipulation mit Hilfe von <a href="http://www.prototypejs.org">Prototype</a> realisieren. Doch leider hatte ich so meine Schwierigkeiten mit der Prototype Doku.<span id="more-53"></span></p>
<p>Folgendes war meine Ausgangssituation:<br />
[code lang='xhtml']</p>
<div id="site">
<div id="navigation">Some navigation stuff</div>
<div id="content">Lorem ipsum dolor sit amet, consetetur sadipscing elitr,<br />
  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna<br />
  aliquyam erat, sed diam voluptua.</div>
</div>
<p>[/code]<br />
In dieses div Snippet wollte ich nun ein weiteres DIV Element mit der id <em><strong>contentIntroduction</strong></em> einfügen. Dabei sollte dieses div genau zwischen die zwei bestehenden divs <em><strong>navigation</strong></em> und <em><strong>content</strong></em> eingefügt werden. Ein kurzer Blick in die <a href="http://www.prototypejs.org/api/">Prototype API</a> führte dann auch gleich die<a href="http://www.prototypejs.org/api/element/insert"> Element.insert Methode</a> zu Tage. Leider ist die Dokumentation an dieser Stelle ein wenig dürftig, weshalb ich zunächst auch etwas rumprobieren musste, bis ich es wirklich verstanden habe.</p>
<p>Für mein beschriebenes Problem müsste die <a href="http://www.prototypejs.org">Prototype</a> Variante also folgendermaßen aussehen.<br />
[code lang='xhtml']<br />
var contentIntroductionElement = new Element('div', {<br />
  'id'   : 'contentIntroduction',<br />
  'class': 'intro',<br />
}).update('This is a simple and short content introduction');</p>
<p>var contentElement = $('navigation');</p>
<p>Element.insert(contentElement, {'after': contentIntroductionElement});<br />
[/code]</p>
<p>Zu lesen ist das Ganze folgendermaßen. Klasse Element, hole Dir das DOM-Element <strong><em>navigation</em></strong> und füge danach das DOM-Element <strong><em>contentIntroductionElement</em></strong> ein. Es muss natürlich nicht nur before sein. <a href="http://www.prototypejs.org">Prototype</a> lässt auch <strong><em>before</em></strong>, <strong><em>top</em></strong> und <strong><em>bottom</em></strong> zu.</p>
<p>Das Ergebnis sind dann folgendermaßen aus:<br />
[code lang='xhtml']</p>
<div id="site">
<div id="navigation">Some navigation stuff</div>
<div id="contentIntroduction" class="intro">This is a simple and short<br />
  content introduction</div>
<div id="content">Lorem ipsum dolor sit amet, consetetur sadipscing elitr,<br />
  sed diam nonumy eirmod tempor invidunt ut labore et dolore magna<br />
  aliquyam erat, sed diam voluptua.</div>
</div>
<p>[/code]</p>
]]></content:encoded>
			<wfw:commentRss>http://leine.info/2009/01/prototype-insert-oder-wie-fuge-ich-elemente-richtig-ein/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

