select-your-own-seat

Expand History Expand History
Collapse History Collapse History

Add seats#show route and action

Render the contents of the seats#show controller action into the same template as seats#index, then embedded the template within a block wrapped by a browser-native <dialog> element declared as a sibling to the seats#index elements.

To achieve this, pass template: "seats/index", along with the template’s local_assigns into a call to render from within app/views/seats/show.html.erb.

seat show page

The modal <dialog> element

When rendering the seats#show template, specify that the wrapping <dialog> element has the open attribute.

When initially rendered (and in environments with JavaScript disabled), the <dialog> element will be overlaid on top of the rest of the page.

In JavaScript-capable environments, within turbolinks:load events, find <dialog> elements and ensure their browser compatibility by wrapping them in calls to the dialog-polyfill-provided registerDialog.

Then, for elements that specify the open attribute, re-set them to be closed, then manually invoke dialog.showModal() to render the dialog modally.

opening and closing the modal