The template has a destroyed event but that event is call when the template is no longer in the dom.
I want to access the template before is take off the dom.
I want to close a tooltip before i can put another template in the dom and close old one.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
destroyedis the only template teardown event that Spark exposes right now. I don’t think we actually guarantee whether it is called before the nodes are physically removed from the DOM, or after.I’m not totally sure, but it sounds like what you’re trying to do is to manually create a floating tooltip DIV after your template is created (I guess from a mouseover event handler or maybe even from
created), and then manually remove it from the DOM when the template goes off the screen. Here some ways to solve this problem:Instead of manually creating the tooltip DIV, put it inside the template, and change the class to show/hide it (maybe using a session variable that is set based on where the mouse is hovering.)
Hold a pointer to the tooltip DIV in a
tooltipattribute on the template object. Then fromremoved, you can just removethis.tooltip.Give the tooltip a unique id or class name, and use jquery or
querySelectorAll(or Meteor’s not-yet-documentedDomUtils.find) to find the element by id or class and remove it.If this isn’t sufficient, I’d be open to adding more functionality, but I’d need to better understand what you’re trying to do 🙂 The best way to request new functionality (other than writing it yourself :P) is to submit a GitHub issue, but it would need to come with a detailed example of what you’re trying to do and why the new hook is needed. Thanks.