package clicktoload import ( "fmt" "examples/shared" ) templ demo(users []user, page int) { @tbody(users, page)
Name Email ID
} templ tbody(users []user, page int) { for _, u := range users { { u.name } { u.email } { u.id } } @replaceMe(page) } templ replaceMe(page int) { } templ Index(users []user) { @shared.Layout("Click to Load") {

Click to Load

This example shows how to implement click-to-load the next page in a table of data. The crux of the demo is the final row:


	@shared.Raw() {
		@replaceMe(1)
	}

This row contains a button that will replace the entire row with the next page of results (which will contain a button to load the next page of results). And so on.

Demo

@demo(users, 1) } }