Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Nice to see someone with so much street cred using Meteor! The best way to get the value is with <a href="http://docs.meteor.com/#eventmaps" rel="nofollow">event.currentTarget</a> and to get stuff from the data contexts there is also another way which needs no DOM knowledge</p> <pre><code>Template.player.events({ 'keypress #name':function(event,context) { //Get the event sending this' value console.log(event.currentTarget.value) //Traverse the DOM on the template 'player' in this case console.log(context.find('#score').value) } }); </code></pre> <p>Basically the best way to get the value of the sender is to use <code>event.currentTarget</code> to access the DOM for that object sending the event. </p> <p>The reason it's implemented this way is probably because any dom object can send an event and it won't necessarily always have a <code>value</code> field so a slight bit of knowledge of the DOM is required when handling the event maps but using <code>event.currentTarget.value</code> works for most form fields</p> <p><strong>Data contexts</strong></p> <p>Regarding the data contexts you should be able to use the data available in the templates from the helpers, e.g if theres a <code>{{score}}</code> &amp; a <code>{{name}}</code> value in the template or a helper, which is passed in this case via the <code>{{#each}}</code> for each individual player.</p> <pre><code> this.name, this.score; </code></pre> <p>Which is also the same as (I usually use <code>context</code> in my helper but <code>template</code> is another way of callng it i guess like in travellingprog's answer)</p> <pre><code> context.data.name, context.data.score; </code></pre> <p>The <code>this</code> helps get data from the template's data context into event's so that one doesn't have to use hidden HTML attributes containing data, e.g with how the player is removed its a bit cleaner than storing the <code>_id</code> in the dom somewhere. That being said <code>event.currentTarget</code> or <code>context.find(..)</code> are the best way to get the data from a textfield.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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