I have a jquery where we are trying to track what documents our users are viewing in our Document Library. Users can upload a document and there is a pagination widget as well.
This is the jquery
$(document).ready(function(){ //
$(".FileCabinet a").click(function () {
//$(document).on("click", "a", function() {
if (! $(this).attr("href") ) {
return;
}
else {
var href = $(this).attr("href");
var mystring = href.replace(/.*\?/,''); //remove everything before the ?
var mystring1 = mystring.replace(/\&.*/,''); //remove the hash key
var mystring2 = mystring1.replace(/[^\d\.]/g, ''); // remove non-numerics
}
alert(href);
$.ajax({
type: "POST",
url: "/CMSPages/WebService.asmx/WhoClicked",
data: JSON.stringify({ DocumentID: mystring2}),
contentType: "application/json",
success: function (data) {
// Do something on sucess
},
error: function(jqXHR, status, errorThrown) {
// Do something on failure
}
});
});
});
Whenever there is a partial postback, the jquery does not fire anymore. I am assuming it has something to do with the document ready function. Is there a workaround for this. In other words how do I make this script fire on each time a document link is clicked.
Open in new window
Try this
Open in new window