Skip to content

the difference between ajax init and document ready init? #195

@vipkouyu

Description

@vipkouyu

I have two pages with different initial ways, pageA is ajax, the other pageB is document.ready
The document.ready ways works well, and the ajax ways have two problems:

1、there is nothing happened when you click the next button, but the other three buttons( first previews last) are fine.
2、After initial, I Can't recognize the current page(should be with active class with background color)

How to fix it? code as follows.

HTML
<div class="row"> <div class="col-md-12"> <div> <div class="text-center" style="padding-top: 0.5em;"> <ul id="pagination" class="pagination-lg"></ul> </div> </div> </div> </div>

ajax initial(pageA)

function getReply_FirstPage(){
$.ajax({
type: "post",
url: "/postapi/getReply",
data:{postID:$('#hide-postID').val(),currentPage:1},
success: function(data) {
$('#div-reply').html(data);

		// alert($('#hide-totalPage').val());
		// alert($('#hide-currentPage').val());

		$('#pagination').twbsPagination({
			totalPages: $('#hide-totalPage').val(),
			startPage:$('#hide-currentPage').val(),
			visiblePages: 10,
			initiateStartPageClick:false,					
			onPageClick: function (event, gPage) {					
				alert(gPage);
			}
		});
	
	}
});	

}

document.ready(pageB,works fine)

       $(document).ready(function(){			
	 	$('#pagination').twbsPagination({
			totalPages: <%= page.totalPage %>,
			startPage:<%= page.currentPage %>,
			visiblePages: 7,
			initiateStartPageClick:false,
			hideOnlyOnePage:false,				
			onPageClick: function (event, page){
				var u='/profile/post/'+page;
				window.location.replace(u);	
			}
		});
	})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions