iron router - Meteor client side collection needs to have all data populated before anything else -


I'm trying to use the client side store as a site configuration system. I incorporate the documents representing my various pages, and using the iron-router and navigation tabs, they use all to determine which pages they are and their Which templates are presented by each page a {{& gt; ContentTemplate}} The Insertion Assistant has to load this relevant template.

It all works great, when all the data is loaded. When I restart the app on some pages, the data is not loaded yet, and I get an exception from the Dipes Recomputing Function: Error: Expected faucet or template was found in exchange for the included function: Undefined < / code> error.

Here is my javascript:

  Storyrere = [{Category: 'Teaching', Content Template: 'teachingHome', Title : 'Teaching Home'}, ...]; Stories = New Meteor. Compile (empty); Story More Year (function (story, index) {story._id = index + ''; storyjinst (story);}); // in main.js Template.teachingPost.contentTemplate = function () {console.log (this); Console.log (this.contentTemplate); Return template [this.contentTemplate]; }; // in router.js this.route ('teaching', {layoutTemplate: 'teachingPost', data: function () {back stories.fundon ({content title: 'teaching home', category: 'teaching'})}} }); Log on twice to   

console contentTemplate assistant, for the first time in this form:

  object {} main JS? 1f560c50f23d9012c6b6dd54469bb32b99aa4285: 45 undefined main.js? 1f560c50f23d9012c6b6dd54469bb32b99aa4285: 46   

and second time like this:

  object {category: "teaching", contentTemplate: "teaching home", title: "Teaching Home "} main. Js? 1f560c50f23d9012c6b6dd54469bb32b99aa4285: 45th Home of Education: JS? 1f560c50f23d9012c6b6dd54469bb32b99aa4285: 46   

So the router is just trying to load this data very quickly.

I have put the process of loading code into different files in my code, including lib , and even so That it is Meteor.startup , but it is always the same result.

Normal iron-router wait / subscription pattern does not really apply here because it is a client side The memory which is w ith null , which has no server representation, I do not want to for the representation of the server, because it is the static content that no need to go to my server is not.

How can I ensure that this information has already been released?

unchecked, but copy:

return a subscription handle, Or with any ready to the ready method, any task will add the handle to a waiting list.

In addition to this, it is better to use find with data , findOne As Find the collection is empty when an empty cursor will return, as opposed to findOne return undefined . Then try it: router.js this.route ('teaching', {layoutTemplate: 'teachingPost', data: function () {return stories. Search ({contentTemplate: 'teaching home, category:' Learning}}}, wait: function () handle {var handle = {} handle.read = function () {if (Stories.find). Count ()! == 0) return true; and false return;} Return handle;}});

and adjust your Template.teachingPost.contentTemplate function to work with the cursor instead of the object.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -