I’m having a problem with this sample code. When I try to execute someFunc(), I get the error:
Uncaught TypeError: $.twbsPagination is not a function.
<html>
<head>
<script type='text/javascript' src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="//code.jquery.com/jquery.min.js"></script>
<script src="~/Scripts/jquery.twbsPagination.js"></script>
</head>
<body>
...
<td>
<button id="button" onclick="someFunc(); return false;">Display Pages</button>
</td>
<div id="pagination-demo"></div>
...
<script>
function load() {
$('#pagination-demo').twbsPagination({ // THIS WORKS.
totalPages: 35,
visiblePages: 7,
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
}
});
}
function someFunc() {
$.twbsPagination(); // THIS DOESN'T WORK.
}
}
</script>
</body>
</html>
I’ve also tried:
function someFunc() {
$('#pagination-demo').twbsPagination({
totalPages: 10,
visiblePages: 7,
onPageClick: function (event, page) {
$('#page-content').text('Page ' + page);
}
});
}
This doesn’t work, either. I still get the above Uncaught TypeError. How do I fix this? It just doesn’t seem to work when called from the onClick event.