meteor - Data available ("this") from a template event handler -


projects.html

  {{#if projects}}     {{#each projects}}       <div class="project-item">         <div class="project-name">           {{name}}         </div>         <div class="project-settings">           <span class="rename">rename</span>           <span class="edit">edit</span>           <span class="delete">             <!-- here -->           </span>         </div>       </div>     {{/each}}   {{/if}} 

projects.js

  template.projects.events({     "click .project-item .delete": function (e, template) {       e.preventdefault();       debugger       // "this" refers specific project     }   }); 

in event handler, noticed "this" conveniently refers specific object inside template event related to. example, in case, delete button inside each projects block, , handler delete button has this = project. convenient, i'd know scopes , rules more completely. can explain in briefly , point me right document?

this data context sensitive feature. basically, there lexical scope in spacebars helpers. have @ this: http://devblog.me/no-data-context.html

the original pull request here: https://github.com/meteor/meteor/pull/3560


Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -