Skip to content
This repository was archived by the owner on Sep 7, 2020. It is now read-only.

Pre-dismiss hook #157

Closed
Sean-Brown opened this issue Mar 9, 2017 · 5 comments
Closed

Pre-dismiss hook #157

Sean-Brown opened this issue Mar 9, 2017 · 5 comments

Comments

@Sean-Brown
Copy link

Is there a way to hook into the pre-dismiss event (or some equivalent event that gets fired BEFORE the modal is closed)? My scenario is that I have a modal form: if the form is dirty and the user attempts to exit, then I want to pop up a confirmation modal.

I can listen to "OnDismiss" and "OnClose" events to nearly achieve this functionality, but by the point these hooks are reached, the modal has already been closed and is no longer displayed (I want it displayed).

Is there a convenient way to hook into an event BEFORE the dialog is closed (with the opportunity to cancel the close event)?

@dougludlow
Copy link
Owner

dougludlow commented Mar 9, 2017

@Sean-Brown this component is basically a wrapper around the bootstrap modal api. However, it's only listening to the 'shown' and 'hidden' events at this point. We haven't added support for any other events yet, but contributions are welcome.

Resources:
Modal Events
javascript bootstrap modal - cancel closing

@Sean-Brown
Copy link
Author

Sean-Brown commented Mar 9, 2017

I'm gonna try to do that, then submit a PR. I did notice that the app doesn't build after a fresh pull down, i.e. I cloned the repo onto my pc and ran npm i, and that command did not succeed:
image

@dougludlow
Copy link
Owner

@Sean-Brown bummer, I'll have to give it a try here in a little while. My guess is I didn't lock down a dependency and it updated and broke whatever I was using it for.

@Sean-Brown
Copy link
Author

Sean-Brown commented Mar 9, 2017

I got around the build error by updating the @angular/compiler-cli dependency to "^2.0.0" -- was there a reason why it was "^0.6.3"?

dougludlow pushed a commit that referenced this issue Apr 2, 2017
- Migrate project to angular-cli.
- Rename modalInstance to modalWrapper.
- Detect backdrop and keyboard with observables.
- Add ability to dismiss all modals (#161).
- Upgrade to Angular v4 (#160).
- Subscribe to all events (#157).
- Create umd/cjs bundle.
dougludlow pushed a commit that referenced this issue Apr 2, 2017
- Migrate project to angular-cli.
- Rename modalInstance to modalWrapper.
- Detect backdrop and keyboard with observables.
- Add ability to dismiss all modals (#161).
- Upgrade to Angular v4 (#160).
- Subscribe to all events (#157).
- Create umd/cjs bundle.
@dougludlow
Copy link
Owner

This should be available in v0.12. The onShow and onHide events were added. See the readme and the demo for details.

dougludlow pushed a commit that referenced this issue Oct 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants