0
以下显示了如何手动将每个href设置为图像路径并设置类。如何将多个值附加到列表中+ jQuery
$.fancybox([{
'href' : '/image/1.jpg',
'class' : 'iframe'
},
{
'href' : '/image/2.jpg',
'class' : 'iframe'
},
{
'href' : '/image?blob_key={{ path }}',
'class' : 'iframe'
}
], {
'padding' : 0,
如果我有一个环,如何那些附加的“href”和“类别”被包围的花括号如上所示在jQuery的列表的值?
编辑
{% for photo in photos %}
// how to add this "/image?blob_key={{ photo.photo_blobstore_key }} to the $.fancybox ?
{% endfor %}
问题已关闭:
解决了:
var options = [];
{% for photo in photos %}
options.push({
'href' : 'image?blob_key={{ photo.photo_blobstore_key }}',
'class' : 'iframe'
});
对不起。我不熟悉jQuery,因此问了这个简单的问题。问题已解决,因此已关闭。
你已经有循环加载页面时,或者是你动态地添加元素到您的网页? –
请将您的解决方案发布为***答案***,然后,如果可以,请接受该答案。否则系统会认为这个问题没有答案(或者至少是'未解决')。 –
感谢大卫的建议。 :) – MrCooL