Morning All,
I'm having real trouble getting e.preventDefault(); to work.
Here is my code
$('#ListSnapshot a').live('click', function(e){
var url = $(this).attr('href') +' #WebPartWPQ2 .ms-listviewtable';
$('#ListSnapshot').load(url);
e.preventDefault();
});
Could someone explain what I'm doing wrong, I can see the load function work but then the page redirects to the clicked link which I need to prevent.
I have also tried moving e.preventDefault(); to the top of the function, to no avail
Thanks in advance!
Gary
Hi all,
Wow!! Thanks for all your reply's. I will try to answer all your responses. I don't know how to reply to each of your answers so I've edited this so you can all see. (Sorry i'm new to stack Overflow)
I've tried placing the alert('test') into the function and can confirm it works, in fact that's how I knew the load function was in fact working because it pauses the page until I close the alert box. In the meantime the list updates in the background.
Here is all the code I have added to the screen, its a sharepoint page so if i upload the html it will be about 200 pages long:
<script>
$(document).ready(function(){
$('#ListSnapshot').load('http://sharepoint/BS/PMO/TR/IT%20Review/Forms/AllItems.aspx #WebPartWPQ2 .ms-listviewtable');
});
$('#ListSnapshot a').live('click', function(e){
e.preventDefault();
var url = $(this).attr('href') +' #WebPartWPQ2 .ms-listviewtable';
$('#ListSnapshot').load(url);
alert(url);
});
</script>