Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I react to DOM events that Meteor Templates don't support?
    text
    copied!<p>Currently meteor <a href="http://docs.meteor.com/#eventmaps" rel="nofollow noreferrer">supports a limited number of events</a> that we can react to from our template definitions. I would like a way to react to events beyond this predefined list. I want the freedom to add any event, even custom events, to the list of possible events in a template. </p> <p>One idea I had would be to set up a jquery event handler somewhere that listens for the unsupported event and have it set a session variable:</p> <pre class="lang-coffee prettyprint-override"><code>$(form).submit( -&gt; Session.set('formSubmitted', true) </code></pre> <p>And then use that session variable when rendering a template:</p> <pre class="lang-coffee prettyprint-override"><code>Template.confirmation.submitted = -&gt; return Session.get('formSubmitted') </code></pre> <pre class="lang-xml prettyprint-override"><code>&lt;template name="confirmation"&gt; {{#if submitted}} &lt;!-- do whatever --&gt; {{/if}} &lt;/template&gt; </code></pre> <p>But this is just a workaround and doesn't really address the issue. Is there a real Meteor-way of doing this? Is this something I can do with the new <a href="https://github.com/meteor/meteor/wiki/Spark" rel="nofollow noreferrer">Spark</a> implementations?</p> <p><strong>NOTE:</strong> Please ignore the fact that I'm using the submit event here. I know I can just bind a click event to the submit button, but that's beside the point.</p> <p><strong>NOTE 2:</strong> The accepted answer to <a href="https://stackoverflow.com/questions/10646570/how-to-handle-custom-jquery-events-in-meteor">this question</a> is also just a workaround.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload