× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Bootstrap Modals With Blaze + Meteor

Jan 25, 2016
<p>Had do you ever thing on a good way to show / destroy bootstrap modals on meteor in the best way?, if yes here is a little snippet</p> <pre><code class="language-javascript">//First declare the event handler Template.myTemplate.events({ 'click #myButton': function(event, template){ var dataToTemplate = { someData: someValue, someData: someValue }; Blaze.renderWithData('Template.myModal', dataToTemplate, document.body); } }); //Then create the html &lt;template name="myTemplate"&gt; {{! All the modal html here }} &lt;/template&gt; //Launch modal. Template.myTemplate.onRendered(function(){ var tmpl = this; $(tmpl.firstNode()).modal('show'); //this will trigger the modal when it gets rendered. }); </code></pre> <p> </p> <p>But how to desroyt it?,</p> <pre><code class="language-javascript">// Template.myModal.events({ 'hidden.bs.modal #myModal':function(event,template){ Blaze.remove(template.view); } }); </code></pre> <p> </p> <p>Yes.. its this easy.</p> <p> </p> <p><a href="http://docs.meteor.com/#/full/blaze_render">Read more about Blaze</a><br>  </p>
comments powered by Disqus