Browse Source

add prepend to insert demo

pull/850/head
David DeSandro 10 years ago
parent
commit
a1c5b5c5c3
  1. 21
      sandbox/insert.html

21
sandbox/insert.html

@ -12,7 +12,11 @@
<h1>insert</h1> <h1>insert</h1>
<p><button id="insert">Insert</button> <button id="append">Append</button></p> <p>
<button id="prepend">Prepend</button>
<button id="insert">Insert</button>
<button id="append">Append</button>
</p>
<div id="container"> <div id="container">
<div class="item"><b>49</b></div> <div class="item"><b>49</b></div>
@ -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() { eventie.bind( document.querySelector('#insert'), 'click', function() {
// append 3 new items // insert 3 new items
iso.insert( [ getItem(), getItem(), getItem() ] ); iso.insert( [ getItem(), getItem(), getItem() ] );
}); });
@ -78,6 +87,12 @@ docReady( function() {
return item; return item;
} }
function prependItem() {
var item = getItem();
container.insertBefore( item, container.firstChild );
return item;
}
function appendItem() { function appendItem() {
var item = getItem(); var item = getItem();
container.appendChild( item ); container.appendChild( item );
@ -95,8 +110,6 @@ var getText = docElem.textContent ?
function( elem ) { function( elem ) {
return elem.innerText; return elem.innerText;
}; };
</script> </script>

Loading…
Cancel
Save