Fork me on GitHub

Add an Item Using API

<script>
$('document').ready(function(){
	var $demo = $('#demo')
		,html
		,$el;
		
	//item html
	html = '<div class="list-item box">\
		<div class="img left">\
			<img title="" alt="" src="../assets/img/thumbs/arch-1.jpg">\
		</div>\
		<div class="block right">\
			<p class="date">03/15/2012</p>\
			<p class="title">Arch 1</p>\
			<p class="desc">Test description</p>\
			<p class="like">6 Likes</p>\
			<p class="theme">\
				<span class="architecture">Architecture</span>\
			</p>\
		</div>\
	</div>';
	
	$el = $(html);
	
	//init jplist first time
	$demo.jplist({				
		itemsBox: '.list' 
		,itemPath: '.list-item' 
		,panelPath: '.jplist-panel'	
	});
	
	//add item to jplist collection (as last item)
	$demo.jplist({
		command: 'add'
		,commandData: {
			$item: $el
		}
	});
	
	//add item to jplist collection in the given index
	$demo.jplist({
		command: 'add'
		,commandData: {
			$item: $el
			,index: 0
		}
	});	
	
});
</script>