Lusty
Lusty

Reputation: 105

Meteor IF statement should be firing

I'm stumped as to why part of my code isn't displaying when the session variable is set to true. When the user selects a certain option from the dropdown, based on the value, it changes the warmerselected to TRUE. I have tracked this in the console, and it works just fine.

Here is my code:

HTML:

<div class="item">
  <div class="ui label">Product Type:</div>
    <select  id="ProductType" name="ProductType">
      {{#each ProductTypes}}
         <option value="{{ProductTypeAbbrev}}">{{ProductTypeName}}</option>
        {{/each}}
     </select>
 </div>

{{#if warmerselected}}
                <div class="item">
                    <div class="ui label">Name:</div>
                        <input type="text" name="ProductName" placeholder="Enter Product Name">
                </div>
{{/if}}

JS:

Session.setDefault("warmerselected", false);

Template.addProduct.events({

    'change #ProductType': function (e) {
       var selitem =  $("#ProductType").val();
        if(selitem == "WA") {
          Session.set("warmerselected",true)
        }else {
            Session.set("warmerselected",false);
        }
    }

});

Upvotes: 0

Views: 28

Answers (1)

sdooo
sdooo

Reputation: 1881

Template.addProduct.helpers({
   warmerselected: function(){
      return Session.get("warmerselected");
   }
});

Session isn't meant to be helper in HTML, you have to create one

Upvotes: 1

Related Questions