How to get click event value in meteor js?

How to get click event value in meteor Js For example, I want {{name}} this value. My code is shown here showing * undefined * in the warning field. Please check and suggest me.

client JS:
Template.client.events({
    'click .clientrow':function(e,t){

         console.log("You Select Client Row ");
         e.preventDefault();
         alert($(e.target).closest('tr').data('_id'));

    }
});
template:
<template name="client">
<tbody>
    {{#each clientList}}
    <tr class="clientrow">
       <td data-id="{{_id}}">{{cid}}</td>
       <td>{{mrno}}</td>
       <td>{{client}}</td>
       <td>{{formatDate rdate}}</td>
       <td>{{referredby}}</td>
       <td>{{clinecian}}</td>
       <td>{{serviece}}</td>
       <td>{{episode}}</td>
       <td>{{actions}}</td>
    </tr>
     {{/each}}              
  </tbody>
</template>
+4
source share
2 answers

You can easily access the item that was clicked:

'click .something': function(e, t) {
  $(e.target);
}

Now, if you want the data stored in a row to be clicked, you can easily make it accessible using datathe HTML parameters

{{#each items}}
  <tr data-name="{{name}}" data-id="{{_id}}">...</tr>
{{/each}}

Then extract it from the line:

'click .something': function(e, t) {
  alert($(e.target).closest('tr').data('name'));
}
+7
source

. this Handlebars, clientList. , - :

Template.client.events({
'click .clientrow':function(e,t){

     console.log("You Select Client Row " + this.client);
     alert(this.mrno + ' ' + this.client);

}
});
+9

Source: https://habr.com/ru/post/1532448/


All Articles