Redirect to previous after deleting one item

I have an application that contains coachees and for each of them modules (Eg. week 1, week 2,…) and for each module a list of actions.

I can access the module list details page via various paths:

  • Coachee Marc (list details) that include Modules (list-block) > Module (list details)
  • Program Alpha (list details) that include Modules (list-block) > Module (list details)

I would like to be redirected to the previous page (Coachee Marc or Program Alpha) when I delete a module.

Today when I delete a module, I need to select one page where the user should be redirected but this page is not “dynamic” meaning that I can’t select a specific list-details page where I was before.

Also with the delete button I need to select a specific page (like Home by default). I can’t set that to blank and then try to capture the delete event and use a javascript to redirect in the past history.

Any idea how to solve that?