zahra
November 10, 2017, 11:41am
1
im a newbie and unable to find the issue
in /client.js
Template.vip_create.helpers({
venues: function() {
var ven= Meteor.call( ‘getVenueRole’,function(err , result){
if(err) {
console.warn()
}
return result;
});
}
});
in method.js
Meteor.methods({
‘getVenueRole’: function () {
return Meteor.users.find({roles: ‘venue’ ,‘profile.venue.name ’: { $exists: true }
}).fetch();
},
view(html)
{{>afQuickField name=“venue” options=venues firstOption="(Select Venue)" value=partyRepost.venue}}
Your problem lies with the way you are trying to get reactive data from a method (which is non-reactive). The canonical way to do this is by using a 1ReactiveVar
in the template onCreated
, and accessing that in the helper. Something like this:
Template.vip_create.onCreated({
this.result = new ReactiveVar();
Meteor.call'getVenueRole', (err, result) => {
if (err) {
console.warn();
}
this.result.set(result);
});
});
Template.vip_create.helpers({
venues() {
return Template.instance().result.get();
},
});
The only other thing to point out, is that your method will return an array of complete documents (not just venue names). You may want to check out the fields
property of options
: http://docs.meteor.com/api/collections.html#Mongo-Collection-find
3 Likes