Skip to content

Instantly share code, notes, and snippets.

@gentunian
Last active August 26, 2015 19:29
Show Gist options
  • Save gentunian/86583be2035600692523 to your computer and use it in GitHub Desktop.
Save gentunian/86583be2035600692523 to your computer and use it in GitHub Desktop.
reactive dialogs without extra packages?
<template name="dialog">
<div class="modal fade" id="{{dialogId}}">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{dialogTitle}}</h4>
</div>
<div class="modal-body">
{{> Template.dynamic template=modalBodyTemplate }}
</div>
</div>
</div>
</div>
</template>
Blaze.renderWithData(Template.dialog,
{
dialogTitle: 'My dialog Title',
dialogId: dialogId,
modalBody: 'myTemplate'
},
$('body').get(0)
);
Template.dialog.onRendered( function() {
$('#dialogId').on('hidden.bs.modal', function (e) {
Blaze.remove( Blaze.getView( $('#dialogId').get(0) ));
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment