Search code examples
javascriptjqueryhandlebars.js

handelbar js - if and data at a same time is not working inside object


I am trying to get json data value, if it is there means it will display or else that whole element will not be there, but its not working with handlebar js

var data = {
    listBank: [
      {  
                     "enableSavedCards":"false",
                     "enableAxisAccount":"true",
                     "enableCreditCards":"false",
                     "enableNetBanking":"false",
                     "enableDebitCards":"false"
                  },
       {  
           "sample":"valuesample",
       "sample2":"valuesample2"


                  }

                  ]
};

here is the jsfiddle

https://jsfiddle.net/1myd7s5o/1/


Solution

  • You need to ensure that you are referencing the handlebars library, along with jQuery. Here is your jsfiddle with these files referenced. Also, the true/false values in the JSON data have been updated to remove the quotes to enable the IF statements in your code: JSfiddle

      listBank: [{
      "enableSavedCards": false,
      "enableAxisAccount": true,
      ....