1.4.0
Improvements
Enable AJAX delete
For usability reasons you might want to delete a row in a paginated table, without the need to refresh the whole page.
All you need to do here is
- Add a specific class to the "post link"
- Add some custom JS to catch the "post link JS"
- Make sure the AjaxComponent is loaded for this action
The default bake action usually already works perfectly:
public function delete($id = null) {
$this->request->allowMethod(['post', 'delete']);
$group = $this->Groups->get($id);
$this->Groups->delete($group);
$this->Flash->success(__('The group has been deleted.'));
return $this->redirect(['action' => 'index']);
}
The JSON response even contains the flash message and redirect URL in case you want to use that in your JS response handling.
A live example can be found in the Sandbox.