From a1c5b5c5c387c15b2ea76e2e289e8fa87a0f1d4c Mon Sep 17 00:00:00 2001 From: David DeSandro Date: Sun, 30 Nov 2014 13:54:37 -0500 Subject: [PATCH] add prepend to insert demo --- sandbox/insert.html | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sandbox/insert.html b/sandbox/insert.html index 3647c88..b13af5b 100644 --- a/sandbox/insert.html +++ b/sandbox/insert.html @@ -12,7 +12,11 @@

insert

-

+

+ + + +

49
@@ -60,8 +64,13 @@ docReady( function() { } }); + eventie.bind( document.querySelector('#prepend'), 'click', function() { + // prepend 3 new items + iso.prepended( [ prependItem(), prependItem(), prependItem() ] ); + }); + eventie.bind( document.querySelector('#insert'), 'click', function() { - // append 3 new items + // insert 3 new items iso.insert( [ getItem(), getItem(), getItem() ] ); }); @@ -78,6 +87,12 @@ docReady( function() { return item; } + function prependItem() { + var item = getItem(); + container.insertBefore( item, container.firstChild ); + return item; + } + function appendItem() { var item = getItem(); container.appendChild( item ); @@ -95,8 +110,6 @@ var getText = docElem.textContent ? function( elem ) { return elem.innerText; }; - -