I'm new to Meteor
(and full stack JS development for that matter) and experimenting a bit trying to convert an app I currently have running on Google App Engine in Django/Python.
I have the following route entry using Iron Router
:
this.route("editFacility", {
path: "/facilities/:_id/edit",
template: "editFacility",
data: function() {
return Facilities.findOne({ _id: this.params._id });
}
});
... and the following template (using autoform's quickform):
<template name="editFacility">
<h2>Edit facility "{{description}}"</h2>
<div class="row">
<div class="col-md-12">
{{> quickForm
collection="Facilities"
omitFields="createdAt, updatedAt"
doc=this
id="updateFacilityForm"
type="update"
template="bootstrap3-horizontal"
label-class="col-sm-2"
input-col-class="col-sm-6"}}
</div>
</div>
</template>
The route gets triggered by:
{{#linkTo route='editFacility' _id=this._id class="btn btn-default btn-xs"}}Edit{{/linkTo}}
Initially it looked like the form wasn't filled with data, but putting a debugger
statement in the route's data:
function revealed that this function is actually ran twice. The first time finding the document and correctly filling the form, immediately followed by a second time and failing the find thus clearing the form. The stack doesn't reveal any particulars and looks identical for both runs:
I googled the issue and found some references but none with a clear solution. I've updated meteor
and all my packages to the latest & greatest but this issue persists.
So my question, what causes meteor
/ Iron Router
to execute this route entry twice?
Seems like you are missing the package autopublish
from your package list. It's responsible for publishing every data available in the server. Otherwise you need to write a publication and then subscribe it back in the client.