Closed BenjaminHorn closed 10 years ago
+1 I was just about to add this issue. Is the no cancel callback to, for instance, transition route when modal is closed or at least hide x so state isn't compromised?
Hey guys, Actually there is one [e18a4d96dcc3462] in 0.7.0,
All you have to do is make sure your controller has the Em.Evented
mixin, then the modal will trigger a closed
event on the controller.
Please reply if it satisfies you, I will leave this issue opened for now as it still needs to be documented.
Thanks.
@asaf Thank you very much! This approach is quite a nice way of handling the dismissed modal event.
I would like to clarify though that the closed
event is on the component which is where you most listen for it, not on the controller that is creating the modal.
Is there any way that you could render an outlet using a this modal component and pass a form template that would have access to the model
?
a simple sample code would be nice
do you have a code example of handling the closed event on a controller when the modal is programmatically created
@smcclstocks I'll add some example to the showcase
An example using Programitically created modal.
Template:
{{bs-button title="Create Modal" clicked="createModalProgramatically"}}
Controller:
Showcase.ShowComponentsModalController = Ember.Controller.extend(Ember.Evented, {
manualButtons: [
Ember.Object.create({title: 'Submit', clicked:"submitManual"})
Ember.Object.create({title: 'Cancel', dismiss: 'modal'})
],
actions: {
submitManual: function() {
Bootstrap.NM.push('Modal destroyed!', 'success');
return Bootstrap.ModalManager.close('manualModal');
},
createModalProgramatically: function() {
var myModal = Bootstrap.ModalManager.open('manualModal', 'Hello', 'demo-template', this.manualButtons, this);
myModal.on('closed', function() {
console.log(‘MyModal closed); // Every time the modal closes.
});
}
}
});
IMO I'd rather have this as an action than DOM event. So you could pass in the name of the action to be called in the component. Ex: {{#bs-modal name='foobar' closed='actionName'}}
Programmatically it would be another argument on the .open()
method. Or have both so you can have the .on('closed', ...)
way programmatically as well.
I really suggest you to go with: http://indexiatech.github.io/ember-components/#/component/component.modal/simple
The modal in this library is much cleaner and supports all these features you are looking for !
Asaf.
Is there a hook or something to run some code after the modal has been closed (not with the buttins but with "x").