[英]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.