I have a site that uses AJAX to navigate. I have two pages that I use a click and drag feature using
$(".myDragArea").mousedown(function(){
do stuff...
mouseDrag = true; // mouseDrag is global.
});
$("body").mousemove(function(){
if (mouseDrag) {
do stuff...
}
});
$("body").mouseup(function(){
if (mouseDrag) {
do stuff...
mouseDrag = false;
}
});
I just type that out, so excuse any incidental syntax errors. Two parts of the site use almost identical code, with the only difference being what is inside the $("body").mouseup()
function. However, if I access the first part, then navigate to the second part, the code that runs on mouseup doesn't change. I have stepped through the code with firebug, and no errors or thrown when $("body").mouseup()
is run when the second part loads.
So, why doesn't the event handler change when I run $("body").mouseup()
the second time?