简体   繁体   中英

How to display particular client name in next template using `meteor Js`?

I need help for how to display particular client name in next template using meteor js. Here is my code verify and give me any suggestion .Route template is also placed see once.

template:


 <template name="clientedit">
    <table>
            <tr>
            {{#each clientList}}
                <td>{{client}}</td>
            {{/each}}
            </tr>
                 </table>
</template>
    <template name="client">
            {{#each clientList}}
               <tr class="clientrow">
                <td >{{client}} <button class="openpopup">open</button></td>
              </tr>
            {{/each}}
           </template> 
            clientJs:
            Template.clientedit.clientList = function () 
             {
                console.log(">>>>>>>>>>>>>>>>>>> clientList "+H_client.find().count());     
               return H_client.find();         
            };

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

                     console.log("Client Name :"+ e.target.innerHTML);
                     e.preventDefault();         
                     Session.set('menuchange' , 'clientedit');

                }
            });

Give this a shot:

template:
{{#each clientList}}
   <tr class="clientrow">
    {{! When we loop through "clientList" each new "this" is an actual "H_client"
        so we can just grab the name off of it! }}
    <td >{{name}} <button class="openpopup">open</button></td>
  </tr>
{{/each}}


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

         // notice, we can just grab this.name since this event happens inside the DOM context
         console.log("Client Name :"+ this.name);
         e.preventDefault();         
         Session.set('menuchange' , 'clientedit');

    }
});

So here we only changed two things. One was to access the name property off of a single H_client document. The second was to access the name via the context in the event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM