I have come across a little problem and can't seem to be able to make it work.
I have this as markup.
<div id="label-group" class="label-group">
<!-- Label Item -->
<div id="label-1" class="label-item">
<div class="label-line">
<a href="#" class="btn btn-small btn-simple btn-assign-schedule">Assign Schedule to Label</a>
</div>
<div class="label-head clearfix">
<div class="label-title">
UK Call Menus
</div>
<div class="label-tools">
<a href="#" class="delete" title="Delete Label"></a>
<a href="#" class="moveup" title="Move Up"></a>
<a href="#" class="movedown" title="Move Down"></a>
<a href="#" class="toggle" title="Open & Close"></a>
</div>
</div>
</div>
</div>
And this jQuery that takes all the label-tools links and adds certain functionalities on click.
$(".label-group .label-tools a").each(function(){
$(this).on('click',function(e) {
e.preventDefault();
var li = $(this).closest(".label-item");
if ($(this).hasClass('movedown')) {
li.css('opacity','0.5');
li.next().css('opacity','0.5');
li.insertAfter(li.next()).animate({opacity:"1"},200);
li.prev().animate({opacity:"1"},300);
} else if ($(this).hasClass('moveup')) {
li.css('opacity','0.5');
li.prev().css('opacity','0.5');
li.insertBefore(li.prev()).animate({opacity:"1"},200);
li.next().animate({opacity:"1"},300);
} else if ($(this).hasClass('toggle')) {
var liContent = $(this).closest(".label-head").siblings('.label-content');
liContent.toggle(0,function(){
li.toggleClass('label-open');
});
} else if ($(this).hasClass('delete')) {
li.remove();
}
})
})
When I add another .label-item to .label-group dynamically the label-tool links don't work at all.