Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vipkouyu opened this issue May 10, 2020 · 0 comments
Open

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

vipkouyu opened this issue May 10, 2020 · 0 comments

Comments

@vipkouyu
Copy link

vipkouyu commented May 10, 2020

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);	
			}
		});
	})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant