我想創建儘可能多的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請求? –