2014-12-28 140 views
0

我“米试图重新计算自动运行的收集更新, 我只设法得到它时,添加以下代码autopublish.the作品完美地工作。跟踪器自动运行

Tracker.autorun(function() { 
    var pages = Posts.find().fetch(); 
    _.each(pages, function(page) { 
     console.log("react"); 
     if (typeof page.adress !== 'undefined' && 
      typeof page.lat !== 'undefined' && 
      typeof page.long !== 'undefined') { 

      var objMarker = { 
       id: page._id, 
       lat: page.lat, 
       lng: page.long, 
       title: page.name 
      }; 

      // check if marker already exists 
      if (!gmaps.markerExists('id', objMarker.id)) 
       gmaps.addMarker(objMarker); 

     } 
    }); 
}); 

}

我需要的是对认购反应 我对本出版物中定义:

Meteor.publish('allposts', function() { 

回报Posts.find({}); });

回答

1

从你的代码看起来像订阅客户端上的记录丢失

试试这个

remove autopublish package 
服务器上

发布记录

Meteor.publish('allposts', function() { 
    return Posts.find({}); 
}); 

在客户端,订阅记录在反应式计算中

Tracker.autorun(function(){ 
     Meteor.subscribe('allposts'); 
}) 

现在在客户端,你可以使用Posts.find({})无论你想要它将被动

+0

完美谢谢你的男人 – Genjuro