0
我在流星的應用程序一對夫婦效用函數看起來像這樣在登錄時失敗:流星反應似乎
Template.registerHelper('canManagePatients',() =>{
const id = Meteor.userId();
const aa = new AccountAccess(id);
const val = aa.canManagePatients();
return val;
});
我的理解是,Meteor.userId()是一個recative數據源,因此登錄後,這些助手的狀態應該改變。
不幸的是,它不能這樣工作,除非我重新加載,這些選項在登錄後仍然隱藏。我錯過了什麼?
這是AccountAccess類如何使用用戶名:
constructor(userId){
if (typeof userId !== "undefined"){
this._userId = userId;
} else {
this._userId = Meteor.userId();
}
}
canManagePatients(){
const practice = this.getCurrentPractice();
if (!practice){
return false;
}
const patientTagId = this._getPatientAdminTag()._id;
const ownerTagId = this._getOwnerTag()._id;
return practice.tags.some((obj)=>{
return (obj === patientTagId || obj === ownerTagId);
});
}
更新
這是一個什麼樣的模板看起來像一個摘錄。所有的作品,除了四個{{#if }}
語句登陸後一重裝後正常運行了精細
<div id="navbar" class="navbar-collapse collapse">
{{#if Template.subscriptionsReady}}
<ul class="nav navbar-nav navbar-right">
{{#if currentUser}}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
{{practice.name}}<br><b>Hello {{userName}}</b> (Not you? <b><u>Logout</u></b>)<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{{#if canManageUsers}}<li><a href="/manage-practice/users/">Manage Users</a></li>{{/if}}
{{#if canManageForms}}<li><a href="/manage-practice/registration/">Manage Registration Settings</a></li>{{/if}}
{{#if canManageForms}}<li><a href="/manage-practice/forms/">Manage Forms</a></li>{{/if}}
{{#if canManagePatients}}<li><a href="/manage-practice/reports/">Reporting</a></li>{{/if}}
<li role="separator" class="divider"></li>
<li><a href="/widgets">Use compact UI</a></li>
<li><a href="/dashboard">Use old UI</a></li>
<li role="separator" class="divider"></li>
<li><a id="linkLogout">Logout</a></li>
</ul>
</li>
{{/if}}
</ul>
{{/if}}
</div><!--/.nav-collapse -->
你的模板是什麼樣的? – MasterAM
在引導下拉列表中,我有這樣的行......'{{#if canManagePatients}}
不需要用javascript初始化下拉菜單嗎? –