I am trying to implement a list of array items from a json file,more list the list you find on google plus,but i am new to programming and dont know how to do it using javascript.Please help.I tried the following but im getting a blank page;
var records = {
"states": [
{
"name": "johor",
"command": "view_johor"
},
{
"name": "selangor",
"command": "view_selangor"
},
{
"name": "melaka",
"command": "view_melaka"
},
{
"name": "kuala lumpur",
"command": "view_kl"
},
{
"name": "penang",
"command": "view_penang"
}
]
};
$.each(records.states, function (key, val) {
$('#ul').append($('<li>').text('name: ' + val.name + ', command: ' + val.command));
});
and html:
<ul id="ul"></ul>
And i dont understand how list.js and data.js work as list plugins.I managed to display a list from json file using handlebars but gave up along the way as i couldnt figure out the onclick item display content of selected item in handlebars.Now im trying to do it the old fashioned way,using javascript.