bart93
August 3, 2015, 7:04am
1
Hi there!
I have akward problem. My collection/publish is loading three times on one page. Dou you have any idea?
I want to publish the “PLN” string, but my page load pulications more than once.
I have some subpages here, maybe that’s why it’s loading three times, but why on second and third loading my currency is “undefined” even though I have the same currencyId “zloty”?
Steve
August 3, 2015, 7:12am
2
Please post a simplified code snippet here, so that we can see what you are doing.
bart93
August 3, 2015, 7:15am
3
That’s a relly cutted snippet
In my html:
<template name="InvoicesEditEditForm">
Total Amount: {{cenka invoice_edits._id}}
{{currencyinfodetails222 invoice_edits.customerId}}
<template>
In my js:
Template.InvoicesEditEditForm.helpers({
"cenka":function(invoiceId){
cena = Invoices.findOne(invoiceId);
cenkadwa = cena.totalAmount;
cenkatrzy = cenkadwa.toFixed(2);
return cenkatrzy;
},
"currencyinfodetails222":function(customerId){
var customerek = Customers.findOne(customerId);
var walutka = customerek.currency;
walutka2=Currency.findOne(walutka);
var walutaname = walutka2.name;
return walutaname;
},
});
And the “cenka” is work properly, byt the “currencyinfodetails222” isn’t.
Of course I have:
Meteor.subscribe("customers"),
Meteor.subscribe("invoice_edits", this.params.invoiceId),
Meteor.subscribe("currency"),
and
customers: Customers.find({}, {}),
invoice_edits: Invoices.findOne({_id:this.params.invoiceId}, {transform:function(doc) { var sum = 0; Invoices.find({ invoiceId: doc._id }).map(function(item) { sum += item.amount; }); doc.totalAmount = sum; return doc; }}),
currency: Currency.find({}, {}),
bart93
August 3, 2015, 7:26am
4
I see that it doesn’t take the object here of my currency. But… in the first time it takes… akward.
Are you using Iron Router? Maybe this SO post might help:
meteor, iron-router
bart93
August 3, 2015, 7:33am
6
Yeah, I use iron:router. I’ll see - thx
EDIT:
Nope, It doesn’t help.
bart93
August 3, 2015, 8:16am
7
There is no answer… It’s bad. Iron router fires data 3 times…
But I don’t know how to stop afetr loading data once
bart93
August 3, 2015, 8:31am
8
OK, I know what to do.
I need to add every publication of my collection to subpages. Now it works