Facing Issue on Loading JSON to Bootstrap Tab
Can you please take a look at this demo and let me know why I am not able to load the second layers of data in the JSON to
bootstrap tab `
tab-content
`
?
- var data = {
- "action": [{
- "id": "1001",
- "name": "Matrix"
- },
- {
- "id": "1002",
- "name": "IP Man"
- },
- {
- "id": "1003",
- "name": "Revenge"
- }
- ],
- "comedy": [{
- "id": "2001",
- "name": "Iceman"
- },
- {
- "id": "2002",
- "name": "Pat & Mat"
- },
- {
- "id": "2003",
- "name": "Sugar"
- }
- ],
- "animation": [{
- "id": "3001",
- "name": "Frozen"
- },
- {
- "id": "3002",
- "name": "Tangled"
- },
- {
- "id": "3003",
- "name": "Croods"
- }
- ]
- };
- for (var i in data) {
- $('.nav-tabs').append('<li role="presentation" class=""><a href="#' + i + '" aria-controls="' + i + '" role="tab" data-toggle="tab">' + i + '</a></li>');
- }
- for (var j = 0; j < data[i].length; j++) {
- var obj = data[i][j];
- $('.tab-content').append('<div role="tabpanel" class="tab-pane" id="' + obj.name + '">' + obj.name + '</div>');
- }
and the HTML is
- <div class="container">
- <ul class="nav nav-tabs" role="tablist"></ul>
- <div class="tab-content"></div>
- </div>