jQuery live() ... have to click twice to activate links?
Posted
by neezer
on Stack Overflow
See other posts from Stack Overflow
or by neezer
Published on 2010-03-14T06:20:54Z
Indexed on
2010/03/14
6:25 UTC
Read the original article
Hit count: 419
I have the following bit of code, simply:
$(function() {
$('a.add-photos-link').live('click', function(e) {
$(this).colorbox({
overlayClose: false,
onComplete: function() {
$('#add_photos').submit(function(e) {
// more stuff to do
e.preventDefault();
});
}
});
e.preventDefault();
});
});
However, this only seems to work after single-clicking on the link TWICE. These links are dynamically added to the page (a.add-photos-link
).
Why is this happening and what can I do to fix it so it fires after the first single-click?
© Stack Overflow or respective owner