benkingcode / ember-routable-modal

An ember-cli addon for implementing URL-first modals.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Override Modal Close Functionality

ryanjavens opened this issue · comments

Hey! I love this addon and it has been easy to work with, but I've got a question.

I'm currently using a modal that handles a user creation form for an app and was curious if there was a way to override the behavior when a user clicks out of a modal to close it. I've currently set a cancel button and the typical 'X' in the corner to close the modal to rollback my model on close, but when looking through the documentation I haven't found a way to mimic that behavior when a user clicks away.

I don't mind working on adding a feature like this if it doesn't currently exist if you'd like, but I wanted to double check before I go down that path =).

Thanks!

The way the code currently works, if the user clicks the DIV holding the modal or clicks a direct descendant of that DIV, the modal will close. So just use an extra DIV wrapper inside your modal, such that no matter where the user clicks, they aren't clicking the direct descendant, and you'll be fine.

Here's the offending code, btw: https://github.com/dbbk/ember-routable-modal/blob/master/addon/components/hold.js#L18