Confusion_buddy
Confusion_buddy

Reputation: 348

How to Iterating array data in a table one by one

I have a dynamic table, am try to iterate a array object one by one in table.Am using Mustache template to iterate it.

<tbody>

    <tr>
       <td>{{ip}}</td>  
       **<td>{{#action-allow}}{{.}}{{/action-allow}}</td>**
        </tr>
</tbody>

enter image description here

It should be first Row - Deny only ,Second row- Deny, and third row-Allow etc. But am getting all together. How can i make it one by one. I need exactly like below picture. how to achieve this ? enter image description here

The template what getting is "action-allow":["Deny","Deny","Allow","Deny","Deny"] "

Upvotes: 0

Views: 87

Answers (1)

Ankush Jain
Ankush Jain

Reputation: 1527

try the following. Change action-allow to action only. Here is live demo http://jsfiddle.net/26dAy/2/

var data= '{"action":["Deny","Deny","Allow","Deny","Deny"]}';
var arr=$.parseJSON(data);
var arr2=arr.action;
 $.each(arr2, function(i, item) {
        alert(arr2[i]);
    });

Upvotes: 1

Related Questions