Meteor Conditionally displaying nested templates -


i have template several sub nested templates should conditionally show based on data saved in templatec collection shown below, used if condition in template shown below, having sub templates displayed despite if condition return true or false. can please check code , tell me missing here? thanks

        var templatearray = ['false', 'false'];          template.formbuilderpreview.created = function() {              var cursor = templatesc.find({}, { sort: { templatecode: 1 }});                 if (!cursor.count()) return;              cursor.foreach(function (row) {               //only case 1 return in switch below case 2 never exist                 switch(row.templatecode) {                     case 1: templatearray[0] = true; break;                     case 2: templatearray[1] = true; break;                     default: templatearray[0] = true;                 }              });         };           template.formbuilderpreview.helpers({              template1box: function(){                       console.log(templatearray[0]);  //this returns true                 return templatearray[0];             },             template2box: function(){                     console.log(templatearray[1]); //this returns false                 return templatearray[1];             }          }); 

template:

    <template name="formbuilderpreview">          <div id="fullpage">             {{#if template1box}}                                 {{> temp01}}             {{/if}}              {{#if template2box}}                                         {{> temp02}}             {{/if}}                     </div>      </template> 

you defined array of strings, believe causing trouble, suggest change

var templatearray = ['false', 'false']; 

to

var templatearray = [false, false]; 

and work smoothly


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -