자바 스크립트 :내 콜백의이 코드가 페이지로드시 실행되는 이유는 무엇입니까?
$('#pagination-demo').twbsPagination({
totalPages: 35,
visiblePages: 7,
onPageClick: function (event, page) {
console.log('Why does this run on load?');
}
});
마크 업 : 여기
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://esimakin.github.io/twbs-pagination/js/jquery.twbsPagination.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<ul id="pagination-demo" class="pagination-sm"></ul>
</body>
</html>
JS 빈 : "부하에이 실행을하지 왜"나는 콘솔에 로그인 onPageClick 콜백에서
http://jsbin.com/potekina/1/edit 그 코드가 링크에서 클릭했을 때만 발생해야하는 경우 왜로드에서 실행되는지 이해가 안됩니다. 로드시 왜 실행됩니까? the source에서
JSBin은 보완책이지만 위의 모든 관련 코드도 여기에 추가하십시오. JSBin이 미래에 존재하지 않을 경우를 대비하여 – CodingIntrigue