[jQuery] Click event broken by AJAX - explain please?
Having read the handful of mentions I could find, the underlying 'why'
is still a mystery to me. I tried stepping through the code with
Firebug but can't make out why it's not working, although I have MADE
it work in this manner:
$("a").click(
function() {
var self = this;
setTimeout(
function() {
$.get(
$(self).attr('href'),
function(html){
<...put the html into a textbox...>
}
)},
500
);
return false;
}
So what is the actual reason when the .get() executes, the return
false never happens, unless I do the setTimeout trick to effectively
move the get OUT of the click function?
If I just have in-line code, no AJAX action, the code proceeds merrily
along to the return and suppresses my event-bubbling nicely.
When I step through the code WITH an AJAX action in there (no
setTimeout), then execution never returns to the 'return'.
I concede that's just the way it is, but I would like to understand
why it's that way. Bug, design tradeoff, was overlooked by developer,
can't be done for some reason because of javascript architecture,
other?