I am publishing data at server and subscribing it at client. For the first time data at the client is displayed but for subsequent events i have to refresh the page for displaying the new data otherwise its displaying the previous data. Its not a synchronization issue as i am using autorun. Below is the code: I can see for each sumit event server is sending the correct data to the client but the client is displaying the older data until page is refreshed. the minimongo is also displaying the previous data. when i used console.log(Counts.find()) its displaying the correct number of records for the new data set fetched. But when i used console.log(Collection_name.find().count()) it displays the number of records of the previous dataset.
Below is my code:
var pageSession = new ReactiveDict();
var location = new ReactiveVar("");
var profession = new ReactiveVar("");
var hospital = new ReactiveVar("");
Template.adssearchResultsTable.onCreated(function searchResultsSearchBoxOnCreated() {
var instance = this;
instance.autorun(function() {
pageSession.set(“ready”,"");
var sub1 = instance.subscribe(‘adv_search’,location(),profession(),hospital(),0);
if(sub1.ready()){
pageSession.set(“ready”,“ready”);
}
});
});
Template.adssearchResultsTable.events({
“submit .SearchBox”: function(e, t) {
e.preventDefault();
pageSession.set("SearchResultsSearchBoxInfoMessage", "");
pageSession.set("SearchResultsSearchBoxErrorMessage", "");
var locat = $("#location").val();
var prof = $("#profession").val();
var hosp = $("#hospitals").val();
FlowRouter.go("/advanceSearch/:searchType",{searchType:"Advance"},{location:locat,profession:prof,hospital:hosp});
}
});
Template.adssearchResultsTable.helpers({
"adstableItems": function() {
console.log(Joblist.find({}, {}).count());
return Joblist.find({}, {});
});