Initiate a template iteration in Meteor -


rather loading new template, there way force meteor initiate iteration (using {{#each}}) of array in meteor? example, if user selects value in pull down selector, initiate meteor iterate through array within template populate multiple selector list rather load whole new template new selector list.

let's within template:

 .  .   .   <form class="input-field col s6 card-selector">       <select multiple">           <option value="" disabled selected>select students</option>           {{#each studentlist1}}                <option value= '{{fullname}}'>{{formatname fullname}} ({{level}}) {{roomwk1}}</option>             {{/each}}         </select>  </form> . . . 

when user selects value in different selector in template:

<select class="week-selector">       <option value="" disabled selected>week</option>       <option value="week1">week 1</option>       <option value="week2">week 2</option>       <option value="week3">week 3</option>       <option value="week4">week 4</option>       <option value="week5">week 5</option> </select> 

it force reiteration of first #each to:

<form class="input-field col s6 card-selector">   <select multiple">       <option value="" disabled selected>select students</option>       {{#each studentlist1}}            <option value= '{{fullname}}'>{{formatname fullname}} ({{level}}) {{roomwk2}}</option>         {{/each}}     </select> </form> 

it more efficient loading new template that's same except multi selector values.

sessions reactive , can achieve using sessions (check if have session package).

//we don't want session value previous search/events template.templatename.onrendered(function(){     session.set('sessionname', undefined); });  //i'd use ondestroyed instead of onrendered template.templatename.ondestroyed(function(){     session.set('sessionname', undefined); });  //template events 'change .week-selector': function(){     var selected = $('.week-selector').find(":selected").text();     session.set('sessionname', selected) }  //template helper studentlist1: function(){     var session = session.get('sessionname');     if(session !== undefined){         //return documents using session value in find()     } else {         //return documents without session value     } } 

edit: found .text() of selected option in event free return value or whatever want found value/text.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo