Need help with this one, been cracking my head for days to get it work.
Referring to this demo http://jsfiddle.net/8QkEw/313/, how do I modify my code to enable inner hyperlinks to work while expanded/selected itemSelector stay expanded/selected.
$(function(){
var $container = $('#container'),
$items = $('.item');
$container.isotope({
itemSelector: '.item',
masonry: {
columnWidth: 100
},
getSortData : {
selected : function( $item ){
// sort by selected first, then by original order
return ($item.hasClass('selected') ? -500 : 0 ) + $item.index();
}
},
sortBy : 'selected'
})
$items.click(function(){
var $this = $(this);
// don't proceed if already selected
var $previousSelected = $('.selected');
if ( !$this.hasClass('selected') ) {
$this.addClass('selected');
}
$previousSelected.removeClass('selected');
// update sortData for new items size
$container
.isotope( 'updateSortData', $this )
.isotope( 'updateSortData', $previousSelected )
.isotope();
});
});
It is only when users click on inner hyperlink will NOT minimize the expanded/selected box; clicking other area will still trigger $previousSelected.removeClass('selected');
Thanks in advance.
Stop event propagation on the links:
Here is a demonstration: http://jsfiddle.net/VCmNU/