@@ -95,11 +95,11 @@ There are 4 parts that are needed to get a working, filterable list of resources
9595The main route for your resource list page must support both GET and POST methods.
9696
9797``` php
98- $routes->match(['get ', 'post '], 'users', 'UserController::list', ['as' => 'user-list']);
98+ $routes->match(['GET ', 'POST '], 'users', 'UserController::list', ['as' => 'user-list']);
9999```
100100
101- The controller should then choose between sending either a full HTML page for a GET request, or just
102- sending back the table for POST requests. You might do it something like:
101+ The controller should then choose between sending either a full HTML page for a regular GET request,
102+ or just sending back the table for ajax requests issued via HTMX . You might do it something like:
103103
104104``` php
105105public function list()
@@ -109,7 +109,7 @@ public function list()
109109 // Performs the actual filtering of the results.
110110 $userModel->filter($this->request->getPost('filters'));
111111
112- $view = $this->request->getMethod() == 'post'
112+ $view = $this->request->hasHeader('HX-Request')
113113 ? $this->viewPrefix .'_table'
114114 : $this->viewPrefix .'list';
115115
@@ -151,14 +151,17 @@ Here's how this is used for the list of users within Bonfire.
151151
152152 <div class =" row" >
153153 <!-- List Users -->
154- <div class =" col" id =" user -list" >
154+ <div class =" col" id =" content -list" >
155155 <?= $this->include('Bonfire\Users\Views\_table') ?>
156156 </div >
157157
158158 <!-- Filters -->
159159 <div class =" col-auto" x-show =" filtered" x-transition.duration.240ms >
160- <?= view_cell('Bonfire\Libraries\Cells\Filters::renderList', 'model=UserFilter target=#user -list') ?>
160+ <?= view_cell('Bonfire\Libraries\Cells\Filters::renderList 'model=UserFilter target=#content -list') ?>
161161 </div >
162162 </div >
163163</div >
164164```
165+
166+ Note that the id of the eleent that contains the included table should be with ` id="content-list" ` as it this ` id ` is
167+ the default target for content replacements by the pager and the filter.
0 commit comments