-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(events): add close & dismiss events with preventDefault #158
base: master
Are you sure you want to change the base?
Conversation
Hi @paramburu. Have you seen the
Those two options seem to do exactly what you're trying to do. |
Hi @jbrowning. Thanks for the response. Indeed, I have seen them but they enable or disable the "closablility" of the modal on a global level. What I needed was to enable or disable it depending on validation of elements inside the scope. With this change what I do inside the controller is the following:
Maybe there is another way I couldn't find? |
I see. I don't think this is the best solution because you may encounter race conditions between the broadcasting of the events and the cancellation of the default behavior. As I see it, you have a couple of options:
|
Personally I think I'd rather go with 1. I don't think your use case is common enough to warrant this sort of behavior on |
Thanks @jbrowning for the advice. I'm closing this PR then but still, I don't understand where the race condition might be. In theory every callback attached with $on will run before the if statement. I believe it is useful to have events related with actions since it is a clean way to attach behavior. Even in the original foundation project there are events for almost all of the components. |
You are correct about the race condition concern. It appears that On second thought, your approach may actually work. ui-router takes a similar approach and broadcasts a I'd suggest simplifying the event name. Perhaps something as simple as |
Great! I will change the names and add other events as a proposal some time during this weekend. I saw someone that could benefit from this on issue #157. Regarding the naming convention of angular events: What I've seen on other projects is the ':' separator, like 'camelCaseName:nameSpace'. On this case I've used two namespaces because of the structure of the module but I want to suggest two more possible conventions:
I've used close & closed to mimic the original events (and for brevity) but could be closeStart and closeSuccess. Let me know what you think about them and if it will be merged if I manage to write the most useful events. |
Is this going to be merged? I need broadcasted events just like this, but for dropdown-toggle. |
@BernardoMariano Future of the project is to be decided, see #311 |
Recently I needed a way to prevent a modal from closing. I could do a method in the scope but couldn't control backdrop or
ESC
key.I want to introduce events with preventDefault capabilities so this kind of behavior can be controlled without much "hackery".
I propose naming these events, as you can see in the code, with the following structure:
`action:module:fndtn'
If you are interested please let me know so I can open an issue and propose which events could be beneficial and add them if you want.