jquery-modal icon indicating copy to clipboard operation
jquery-modal copied to clipboard

Show/hide modals when navigating with back/forward buttons

Open soundasleep opened this issue 6 years ago • 3 comments

Using pushState and popState event handlers, we can understand when the modal needs to be closed (and prevents the browser from navigating away), and when the modal needs to be reopened (using the new modal:reopen event).

By default this is turned off, but can be enabled in the modal options with updateHistory: true.

Note that as this stands, this doesn't work very well with Turbolinks: I'm not sure yet if this is a bug on the Turbolinks side or not, but in the meantime, this behaviour works for non-Turbolinks sites.

May resolve https://github.com/kylefox/jquery-modal/issues/197

soundasleep avatar Aug 07 '18 02:08 soundasleep

(This PR doesn't update the minified versions, not sure how you do those)

soundasleep avatar Aug 07 '18 02:08 soundasleep

Update: I don't think there's any way to handle Turbolinks + back button correctly, see https://github.com/turbolinks/turbolinks/issues/264

soundasleep avatar Aug 07 '18 04:08 soundasleep

@soundasleep Looks cool, and thanks for also updating the README 🙂

Would you mind adding an example?

kylefox avatar Aug 11 '18 19:08 kylefox