Jump to content

DataTables - Hide 'Load More' Button When All Rows Are Visible


Manny

Recommended Posts

Hi there,

 

I'm trying to implement an instance of DataTables onto a new site and came across the following link:

 

https://jsfiddle.net/6k0bshb6/20/

 

I have edited the JS section to this:

		$(document).ready(function () {
			var dataTable = $(".datatables").DataTable({
				"autoWidth": false,
				"bLengthChange": false,
				"bFilter": false,
				"bInfo": false,
				"bSort": false,
				"pageLength": 10
			});
			
			// Alternative Pagination
			$("#button").on( 'click', function () {
				var VisibleRows = $('.datatables>tbody>tr:visible').length;
				var i = VisibleRows + 5;
				dataTable.page.len( i ).draw();
			} );
		});

The script does everything I need, with one exception.

 

There are 14 rows in total. Once all 14 rows have been loaded, I want the 'button' to disappear so the user can no longer click it. How can I achieve this?

Edited by Manny
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...