简体   繁体   English

如何使用Meteor Js在下一个模板中显示特定的客户名称?

[英]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. 我需要有关如何使用流星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. 一种是从单个H_client文档访问name属性。 The second was to access the name via the context in the event. 第二个是在事件中通过上下文访问name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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