How to capture modal opening / closing bootstrap in meteor js

I am trying to capture the modal opening / closing of the bootstrap event in meteor js to perform some custom checks. I know how to do this in jquery:

$('#videoCallModal').on('shown.bs.modal', function () { // do somethingโ€ฆ }) 

but since I also want to pass the context (this object), I want to do this in Template.template.events.

I tried something like, but the function was not called:

 Template.videoCall.events = { 'on #videoCallModal shown.bs.modal': function(e){ e.preventDefault(); console.log("modal open", this); } } 

Is there any other way to capture modal closing / opening in meteor js

+6
source share
2 answers

The correct syntax is:

 Template.videoCall.events({ 'shown.bs.modal #videoCallModal': function(e){ /* ... */ } }); 

See meteorpad .

+12
source

I created peppelg: bootstrap-3-modal to provide an easy way to handle modals in Meteor. With it, you can use the created and destroyed callbacks (just like you used in Meteor!) Instead of the open and close events.

+5
source

Source: https://habr.com/ru/post/975463/


All Articles