Hey everyone.
I’m using Blaze.renderWithData
to show a modal window like this:
<template name="fullStatModal">
<div tabindex="-1" role="dialog" id="fullStatModal" class="modal fade">
...
<button class="btn btn-default" data-dismiss="modal">Close</button>
...
</div>
</template>
Template.office.events
"click .officeFullStat": (event, template) ->
Blaze.renderWithData Template.fullStatModal, @_id, document.body
return
So clicking “Close” hide modal but it is still in DOM and next time I click .officeFullStat one more #fullStatModal inserted to DOM.
According to docs I have to manually remove rendered view, but I have no idea how to do it. Now I just remove it with JQuery:
$("#fullStatModal").remove()
But I believe the instance of template with all subscriptions still in runtime.
I guess it should be somethink like this:
view = Blaze.renderWithData Template.fullStatModal, @_id, document.body
Blaze.remove(view)
So let’s say I want to remove view when “Close” button of rendered template clocked. How can I achieve this?