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>
<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 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() {
// 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 );
@ -96,8 +111,6 @@ var getText = docElem.textContent ?
return elem.innerText;
};
</script>
</body>

Loading…
Cancel
Save