Good Day Guys.
my scenario is I want to add a new element which is ul li
on a certain tab which correspond to their own id. the code is working fine.. however I find that .append is much slower than .html... you see in my code if I change the .append
to .html
it will just display the last loop... since .html
delete the existing elements inside and replace a new one...
what I want is to display them via .html
with regards to their id.
OBJECTS
groups = [{
GroupID: 1,
tabPaneID: "home"
},
{
GroupID: 2,
tabPaneID: "edit"
},
{
GroupID: 3,
tabPaneID: "view"
},
{
GroupID: 4,
tabPaneID: "home"
},
{
GroupID: 5,
tabPaneID: "home"
}
];
items = [{
GroupID: 1,
Item: "SampleItem1",
Qty: 21
}, {
GroupID: 1,
Item: "SampleItem2",
Qty: 21
}, {
GroupID: 2,
Item: "SampleItem3",
Qty: 22
}, {
GroupID: 3,
Item: "SampleItem4",
Qty: 23
}, {
GroupID: 4,
Item: "SampleItem5",
Qty: 24
}, {
GroupID: 4,
Item: "SampleItem6",
Qty: 25
}, {
GroupID: 5,
Item: "SampleItem7",
Qty: 25
}];
JQUERY
$.each(settings.tabs, function (i, t) {
$.each(settings.group, function (ObjID, groupObj) {
if (t.tabPaneID == groupObj.tabPaneID) {
$tabPane.find("#" + t.tabPaneID).append("<ul class='delta-ui-common-ul' id=group-" + groupObj.GroupID + "></ul>");
$.each(settings.item, function (itemID, itemObj) {
if (groupObj.GroupID == itemObj.GroupID) {
var list = $tabPane.find("#" + t.tabPaneID);
list.find("#group-" + groupObj.GroupID).append("<li>" + itemObj.Item + "</li>");
}
});
}
});
});