Here my code:
<div class="container" role="main">
<li><a href="javascript:void(0);" onclick="showAssignLabelsInMain(this);">Assign Labels</a></li>
<div class="labelListInMain" id="labelListInMain">
<g:render template=""/>
</div>
</div>
function showAssignLabelsInMain(elm) {
$.ajax({type: 'POST',
url: '${createLink(controller: "HRAdmin", action: "labelListInMain")}',
success: function (data, textStatus) {
$('#labelListInMain').html(data);
}
});
var offset = $(elm).offset();
$("#labelListInMain").css({top: offset.top + 25, left: offset.left - 18, position: 'absolute'});
$('#labelListInMain').toggle('fast');
$(".container").mouseup(function (e) {
var subject = $("#labelListInMain");
alert(e.target.id)
if (e.target.id != subject.attr('id')) {
subject.fadeOut();
}
});
It means that when I clicked the button, toggle will show up, but when I click inside that toggle, it fades out. It is not supposed to fade out and I don't know what's wrong.