![](/img/trans.png)
[英]How to render partial template when particular menu clicked in Meteor JS
[英]How to display particular client name in next template using `meteor Js`?
我需要有关如何使用流星js在下一个模板中显示特定客户端名称的帮助。 这是我的代码验证,并给我任何建议。路由模板也放置一次。
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');
}
});
试一下:
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');
}
});
因此,这里我们仅更改了两件事。 一种是从单个H_client
文档访问name
属性。 第二个是在事件中通过上下文访问name
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.