So imagine this scenario, I have a list, and it has a little pagination, when the user clicks on, the link gets carried away by jQuery, it uses the $.ajax function (from which I quoted below) to go to the next page content and display them in the source container. This includes links to pages, and we also want them to be updated as well.
The first page change works fine, but at this point we have lost the connection between our link element and our jQuery rule:
$('#paging a').click(function(event) { event.preventDefault(); getElementContents('#target_container','',$(this).attr('href'),false);
What parameters do I have to maintain communication between the event and the function?
For reference, here is my wrapper function for $.ajax :
var ajax_count = 0; function getElementContents(target,data,url,highlight) { if(url==null) { url='/'; } if(data==null) { var data=new Array(); } if(highlight==null || highlight==true) { highlight=true; } else { highlight=false; } $.ajax({ url: url, data: data, beforeSend: function() { if(++ajax_count==1) { $.blockUI({message:'Loading data, please wait'}); } }, success: function(responseText) { if($(target).is("input")) { $(target).val(responseText); } else { $(target).html(responseText); } if(highlight==true) { $(target).trigger("change").effect("highlight",{},2000) } }, complete: function () { if(--ajax_count==0) { $.unblockUI(); } }, cache: false, dataType: "html" }); }
Thanks!: -)
EDIT
hmmm, just found this question ... looking at it :-)