This works.
$(document).ready(function(){
$(".items article").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
});
However, when the user navigates to other records trough ajax on that same page, we got an irritant refresh.
(not more irritant that my ignorance about how does that occur btw).
If I change the code to use delegate:
$(document).ready(function(){
$(".items article").delegate('click', function(){
window.location=$(this).find("a").attr("href");
return false;
});
});
I still got the irritating refresh.
If I change it to live, I got it with no refresh.
$(document).ready(function(){
$(".items article").live('click', function(){
window.location=$(this).find("a").attr("href");
return false;
});
});
I’ve read on stackoverflow that we should use delegate instead of live, on this case however, live seems to do the job while delegate doesn’t. OR, am I using it wrongly ?
UPDATE:
So, and using on, by taking the same examples as above:
$(document).ready(function(){
$('#morespecifcelement').on('click','.items article', function() {
window.location=$(this).find("a").attr("href"); return false;
});
});
I still got the page refreshed.
Please advice,
try