I am having a strange problem, a part of jquery code is not working properly until I add breakpoint in firebug, this is the code
function loadPreviousGameCount() {
var $hdnTotalPreviousGamesCount = $('#<%=hdnTotalPreviousGamesCount.ClientID %>');
// load page count only if it is not already loaded
if ($hdnTotalPreviousGamesCount.val() == "-1") {
$.post('MypageUrl&MemberId=<%=MemberId%>',
{},
function(response) {
if (response.IsDone) {
$hdnTotalPreviousGamesCount.val(response.Data);
} else {
$hdnTotalPreviousGamesCount.val(response.Message);
}
}, 'json');
}
}
and I am using this function to intiate paging
function initPagination() {
loadPreviousGameCount();
// I put breakpoint on the below line("var pageCount...")
var pageCount = parseInt($('#<%=hdnTotalPreviousGamesCount.ClientID %>').val());
// Create pagination element
$("#divPager").show().pagination(pageCount,
{
callback: loadPreviousGames,
num_edge_entries: 1,
items_per_page: 5
});
}
So what I am trying to do is, I am loading games count from server and saving it to a hidden field if it is not already been loaded, and that games count I am using for pagination. The code is working perfectly but only either from the second time or if I put a debug point in the very first time.
So I find the value written in hidden field inside initPagination function in two cases
In the second call of initPagination function.
If I put a debug point on the line I mentioned above in the first call.
Any clues?