Publication extending to other templates


#1

I have the following templates:

<template name="reportsContent">
    <ul class="tabs">
        <li class="tabs-content" data-content="summary">
            <div class="tabs-content-wrapper">
                {{> reportsSummary }}
            </div>
        </li>
        <li class="tabs-content" data-content="invoices">
            <div class="tabs-content-wrapper">
                {{> reportsInvoices }}
            </div>
        </li>
        <li class="tabs-content" data-content="patients">
            <div class="tabs-content-wrapper">
                {{> reportsPatients }}
            </div>
        </li>
    </ul>
</template>

<template name="reportsSumary">
    ....
</template>

<template name="reportsPatients">
    ....
</template>

I’ve attached a publication to the reportsSummary template, yet it seems to be extending to the reportsPatients template too. I’m not sure why since I’ve followed the correct method to define pubs/subs (I think…)

Here’s my publication:

Meteor.publish('appointments.day.patients', function () {

    var thisMonth = new RegExp(moment().format('MMM YYYY'));

    return Appointments.find({
        date_created: { $regex: thisMonth }
    }, { fields: { date_created: 1 } });
});

And here’s my subscription:

Template.reportsSummary.onCreated(function () {
    this.subscribe('appointments.day.patients');
});

It’s not that what I have is breaking any functionalities per se. I’m just worried about efficiency when the app has a whole lot of data that it has to sift through. Am I missing something here?


#2

It looks like all the templates (reportsContent, reportsInvoices, reportsSummary andreportsPatients) are displayed on the same page at the same time. That means that your template subscriptions cannot be torn down, so you local minimongo will continue to hold the (merged, if any) content of all these template subscriptions on Appointments.


#3

Aah. Right, that makes sense! I was using jQuery to hide the element depending on what I had wanted to show, so it slipped my mind that the template was still there, just hidden.