Meteor - 模板级订阅未加载数据

时间:2016-03-10 05:32:47

标签: javascript meteor

我对这个特定页面有三个订阅。三个模板级订阅中的两个完美地工作,第三个不是并且正在挂起页面。在控制台或服务器窗口中根本没有抛出任何错误。我有几个模板级订阅的其他页面没有任何问题,对于我的生活,我无法弄清楚我在这里做错了什么。

我所拥有的内容如下:

Template.billingBoardTemplate.onCreated(function(){

  var self = this;

  // dynamic subscribes go here
  self.autorun(function(){
      // loading the collections we will need for this page
      self.subscribe('companyProfile');
      self.subscribe('trips', companyCode.get(), 'subscribeBillingBoard');
      self.subscribe('customers', companyCode.get(), 'subscribeBillingBoard', billingCustomerId.get() );

  });
});
工作的两个是旅行和客户,而公司的一个不是。 。以下是服务器上的发布设置。

Meteor.publish("companyProfile", function () {
if (this.userId){
    return companyProfileColl.find();
};
});

Meteor.publish("trips", function (companyCode, tripsSearchType) {
if (this.userId){
    if(tripsSearchType === "subscribeAll"){ // old method of subscribing
        return tripsColl.find({companyCode: companyCode});
    }

    if(tripsSearchType === "subscribeBillingBoard"){ // subscribing to trips and fields required for the billing board.
        return tripsColl.find({companyCode: companyCode, tripOverAllStatus: "Delivered"}, {fields: {
            tripNumberText: 1,
            companyCode: 1,
            customerName: 1,
            orderLoadNum: 1,
            orderTotalCharges: 1,
            orderCurrency: 1,
            custID: 1,
            orderExtraCharges: 1,
            orderGSTTotal: 1,
            orderPSTTotal: 1,
            orderTAXTotal: 1,
            loadConfUploadPath: 1,
            PODDocsPath: 1,
            "orderPickups.Customer": 1,
            "orderPickups.City": 1,
            "orderPickups.State": 1,
            "orderDeliveries.Customer": 1,
            "orderDeliveries.City": 1,
            "orderDeliveries.State": 1,
            "orderDispatch.stopPuDate": 1,
            "orderDispatch.stopDelDate": 1,
            "orderDispatch.truckNumText": 1,
            "orderDispatch.driverName": 1,
            "orderDispatch.carrierName": 1,
            "orderDispatch.trailerNumText": 1
        }});
    }
};
});

Meteor.publish("customers", function (companyCode, customersSearchType, customerId) {
if (this.userId){
    if(customersSearchType === "subscribeAll"){ // the old method to return all records.
        return customersColl.find({companyCode: companyCode});
    }


    if(customersSearchType === "subscribeReceivables"){ // receivables module, only need customer name and id
        return customersColl.find({companyCode: companyCode}, {fields: {customerName: 1}});
    }

    if(customersSearchType === "subscribeBillingBoard"){ // billing module module,only pulling one record so pulling all of it
        return customersColl.find({companyCode: companyCode, _id: customerId});
    }
};
});

这里不好玩的是,如果我只是在任何函数或任何东西之外直接进行Meteor.subscribe,那么集合就会加载。这让我疯了几个小时,因为我无法看到我在这个和许多其他页面上做过的其他订阅的其他内容。

非常感谢任何帮助。

0 个答案:

没有答案
相关问题