我想创建尽可能多的Materializecss cards,因为Firebase查询后有值。添加尽可能多的卡,因为查询后有值
E.g我做的Jquery:
$(document).ready(function() {
var brandsRef = firebase.database().ref().child("Brands");
brandsRef.once('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var childKey = childSnapshot.key;
//Append cards here card title would be childKey
});
});
});
如果childKey = 5
,我想那5张牌出现与childKey value
。
我知道我可以追加名单如下:
$(".collection").append('<a href="index.html" class=" collection-item">'+childKey+'</li>');
,但不知道如何巢牌。
您需要将卡片创建到您的密钥迭代器(snapshot.foreach)中。这些卡的数据来自ajax请求? –