I am working on Ajax pagination with codeigniter,Pagenation is working fine but i want to get "current/active" page number on jquery, How can i do this ?
Here is my code
<table border='1' width='100%' style='border-collapse: collapse;' id='postsList'>
<thead>
<tr>
<th>S.no</th>
<th onclick='sortTable("emp_name");'>Title</th>
<th>Content</th>
</tr>
</thead>
<tbody></tbody>
</table>
<script type='text/javascript'>
function sortTable(columnName){
var pageno = $(this).attr('data-ci-pagination-page');
alert(pageno);
}
</script>
After Inspect element i am getting following code ( for exmaple my current page is 2, is in strong tag)
<div style="margin-top: 10px;" id="pagination">
<a href="https://unireview.io/backup_171001/Main/loadRecord" data-ci-pagination-page="1" rel="prev"><</a>
<a href="https://unireview.io/backup_171001/Main/loadRecord" data-ci-pagination-page="1" rel="start">1</a><strong>2</strong>
<a href="https://unireview.io/backup_171001/Main/loadRecord/3" data-ci-pagination-page="3">3</a>
<a href="https://unireview.io/backup_171001/Main/loadRecord/4" data-ci-pagination-page="4">4</a>
<a href="https://unireview.io/backup_171001/Main/loadRecord/3" data-ci-pagination-page="3" rel="next">></a>
<a href="https://unireview.io/backup_171001/Main/loadRecord/1750" data-ci-pagination-page="1750">Last ›</a></div>
CodePudding user response:
Add a class (or id) on your active element for example <strong id="acrive"></strong>
and find it in jquery like $('#active')
CodePudding user response:
You can do it using uri->segment
in CI
$this->uri->segment(n); // n=1 for controller, n=2 for method, etc