0

Problem is solved, i made another stupid mistake in my code... sorry, thanks

example:

<div id="window1Header" class="windowHeader">
   Window 1 <a id="min1" class="minimize">[-]</a> <a id="max1" class="maximize">[+]</a>
</div>
<script>
    $(function() {

    $(".windowHeader").mousedown(function () { 
        $(this).parent().css({"border" : "#000 1px dashed"});
        $(this).parent().draggable({ containment: 'parent' });
    });
$(".windowHeader").mouseup(function () { 
        $(this).parent().css({"border" : "#ccc 1px solid"});
        setTimeout(function() {
            $(this).parent().draggable('destroy');
            }, 100);
    });

   $('#min1').click(function(e) {
     e.stopPropagation();
        $("#window1Body").hide().slideUp(500);
});
$('#max1').click(function(e) {
    e.stopPropagation();
        $("#window1Body").hide().slideDown(500);
});

    });
</script>

The outerdiv (window1Header) has a mousedown and up event and the 2 links (min1 and max1) have click-events. But clicking the links wil trigger the event binded to window1Header. How can i trigger the right events? I'm using the jquery library btw.

Any help is appreciated!

Overbeeke
  • 2,006
  • 3
  • 22
  • 23

2 Answers2

2

Generally, use stopPropagation to prevent the event from bubbling to parent elements. E.g.:

$('.minimize').click(function(e) {
    e.stopPropagation();
    ...
});
karim79
  • 339,989
  • 67
  • 413
  • 406
0

You need to at least have an href="#" on your a tags otherwise the click event will never fire. Also, return false in the click events.

 $('#max1').click(function(e) {
    $("#window1Body").hide().slideDown(500);
    return false;
 });
smack0007
  • 11,016
  • 7
  • 41
  • 48
  • Thats not right. I placed the links outside the div and the events where triggered just fine. The problem is with the links being inside the div. The only thing fired when clicking the links is the event of the div, so its not bubbling up it fires the parent event right away. – Overbeeke Sep 27 '09 at 11:10