-1

I've got a popup that I don't want to close unless you click off of it, however it closes whenever I click on it as well. It shouldn't close when you click inside the div with the class of "create-album-container"

$(document).ready(function() {

////posts menu
$(".container").on("contextmenu", ".photos-bottom .albums li", function(e) {
var id = $(this).attr("id");
e.stopPropagation();
e.preventDefault; 
$('.create-album-container').hide();
$('.photos-bottom .albums li#'+id+' .create-album-container').show();

return false;   
});



$("body").click(function (event) {
     $('.create-album-container').hide();
});

});
Dylan Cross
  • 5,918
  • 22
  • 77
  • 118

1 Answers1

2

Should be e.preventDefault(); - it is a function

And did you try to add

$('.create-album-container').click(function(e){
e.preventDefault();
e.stopPropagation();
return false;
});

?

Cheery
  • 16,063
  • 42
  • 57
  • preventDefault works as it should, it's the stopPropagation part that I'm having trouble with. – Dylan Cross Jan 28 '12 at 01:46
  • @DylanCross But stopPropagation is attached to the right click, it is not fully related to your question. – Cheery Jan 28 '12 at 01:51
  • That never even occurred to me, however i'm not having any success either way – Dylan Cross Jan 28 '12 at 01:57
  • @DylanCross So, did you try to prevent propagation for the left click? If yes then do you have a link to the page with your code? – Cheery Jan 28 '12 at 01:59
  • I'm not sure that `.stopPropagation()` will work when you're using delegated events: by the time the event is handled it has already propagated up to the ".container" element, so I think all you can do is stop it propagating even further up. Also, returning `false` from the event handler will automatically do `.preventDefault()` and `.stopPropagation()`... – nnnnnn Jan 28 '12 at 02:06
  • @nnnnnn but that is what he needs - not to pass it to the body click listener. "returning false" just an overhead :))) – Cheery Jan 28 '12 at 02:10
  • Actually I got it figured out, thanks. – Dylan Cross Jan 28 '12 at 02:21