2012-04-28 83 views
2

我在循环中使用模态窗口组件。每个循环内容都有X个具有不同ID的缩略图(模态也有不同的ID),它们应该通过它们的数据切换属性来触发模态,但是模态仅在循环的第一个项目上工作,数据切换仅设置与其余的屏幕的背景。 模式窗口内容和标记在DOM中,只有它们不显示。Twitter引导 - 多模态窗口

我已经尝试删除淡出类,重命名的ID,但我没有运气到目前为止。 我发现了一个similar problem,但这并没有帮助我的情况。

可能是什么问题?

<li class="span3"> 
<div class="modal hide" id="modal1"> 
    <div class="modal-header"> 
     <button class="close" data-dismiss="modal">x</button> 
     <h3>Lipsum</h3> 
    </div> 
    <div class="modal-body"> 
     <p>Lipsum</p> 
    <hr> 
    <img src="<?php the_field('srceenshot')?>"> 
    </div> 
    <div class="modal-footer"> 
     <button class="close" data-dismiss="modal">x</button> 
    </div> 
</div> 
    <a class="thumbnail" data-toggle="modal" rel="popover" data-content="<?php the_field('screenshot_text')?>" data-original-title="<?php the_field('screenshot_header')?>" href="#modal1"> 
     <img src="<?php the_field('screenshot')?>"> 
    </a> 
</li> 

SOLUTION:

<div class="modal hide" id="modal1_<?php echo $count"> 

<a class="thumbnail" data-toggle="modal" rel="popover" data-content="<?php the_field('screenshot_text')?>" data-original-title="<?php the_field('screenshot_header')?>" href="#modal1_<?php echo $count"> 
+0

还要确保调用模式的按钮的'href'引用动态ID。 – 2012-08-03 22:53:32

回答

2

id=modal1需要是动态的。所以它应该是类似于id=modal_<PK of Object>

+1

好吧,我不明白,模态的内容是动态的。你是说我应该添加一个动态生成的后缀到模态的ID? – elbatron 2012-05-08 12:16:15

+0

是的,尝试一下。否则,模态将仅采用最后生成的对象。 – super9 2012-05-08 15:14:57

+0

对不起,我没有时间来实现它,但你是对的:在ID模式1上附加一个计数器可以解决这个问题。 – elbatron 2012-06-23 06:10:29