如何在按钮和模态上重复数据? [英] How can I repeat the data on a button and a modal?

查看:48
本文介绍了如何在按钮和模态上重复数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!!我想知道是否可以重复按钮中的数据和将数据匹配在一起的模态。目前,我有一个带有正确数据的按钮列表,但是当点击它们中的任何一个时,它总是看起来在模态中有第一个数据。



很抱歉这么长的代码:P





Hello!! I was wondering if it is possible to repeat the data in the button AND the modal that matches the data together. At the moment, I have a list of buttons with the right data, but when clicking on any of them it always appears to have the first data in the modal.

Sorry for such a long piece of code :P


<asp:Repeater ID="rptMain" runat="server">
                                        <ItemTemplate>
                                        <div>
                                        <div class="list-group">
    <a href="#" class="list-group-item" data-toggle="modal" data-target="#editmember">
      <p class="list-group-item-text"><%#Eval("name")%> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></p>
</a>
</div>

                                        <div class="modal fade" id="editmember" role="dialog">
    <div class="modal-dialog">
    
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title"><%#Eval("name")%> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></h4>
        </div>
        <div class="modal-body">
          <p><div style="float: left; width: 100%;">
                                                    <div style="float: left; width: 13%;">
                                                        <asp:Image ID="imgPhoto" runat="server" Style="width: 90px; -moz-border-radius: 4px;border-radius: 4px;"
                                                             Visible='<%#Eval("photo").ToString()==""?false:true %>'
                                                            ImageUrl='<%#Eval("photo").ToString()==""?"photo\\no_noimage.png" : "photo\\" + Eval("photo").ToString()%>' />
                                                    </div>
                                                    <div style="float: left; width: 87%;">
                                                        <p>
                                                            <%#Eval("ContactBio")%>
                                                        </p>
                                                    </div>
                                                </div>
                                                <p>
                                                     
                                                </p>
                                                <div style="float: left; width: 100%;">
                                                    <div style="float: left; width: 13%;">
                                                        <asp:Image ID="imgLogo" runat="server" Style="width: 90px; -moz-border-radius: 4px;border-radius: 4px;"
                                                             Visible='<%#Eval("logo").ToString()==""?false:true %>'
                                                            ImageUrl='<%#Eval("logo").ToString()==""?"logo\\no_noimage.png" : "logo\\" + Eval("logo").ToString()%>'/>
                                                    </div>
                                                    <div style="float: left; width: 87%;">
                                                        <p style="font-weight: bold;">
                                                            <%#Eval("subcompany")%>
                                                        </p>
                                                        <p>
                                                            <%#Eval("CompanyDescription")%>
                                                        </p>
                                                    </div>
                                                    </div>
                                                    
                                                
                                                <p>
                                                     </p></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
        </div>
        </div>
        </div>
        </div>
                                        
  
                                        </ItemTemplate>
                                    </asp:Repeater>





我真的很感激一些帮助:)



I would really appreciate some help with this :)

推荐答案

看到问题是你的所有按钮数据 - 目标属性目标到id为target的页面的第一个模态,所以通过使用类名作为数据目标更好地给出目标,并生成唯一每个模型的类名,并给出相应按钮目标的类名。



您也可以使用jquery处理这些,例如为具有特定类名的按钮生成click事件, click事件使用一些data-classname =targetmodelclassname获取当前目标模型类名,然后打开该模式调用open。



更好地关注第一个,只需为模型生成唯一的名称,并将它们定位在按钮中。



希望它能帮到你。
see the problem is all your buttons data-target attribute targets to first modal of the page with id of target, so better give target by using class names as data-target, and generate unique class names for each model, and give those in corresponding button target.

You can also handle these with jquery , like generate click event for buttons with particular class name, in that click event get the current target model class name using some data-classname="targetmodelclassname" and then open that modal calling open.

better to follow first one, just generate unique names for models, and target them in buttons.

Hope it will help you.


 <itemtemplate>
                                        <div>
                                        <div class="list-group">
    <a href="#" class="list-group-item" data-toggle="modal" data-target=".<%#Eval(" youruniqueid=")%>">
      <p class="list-group-item-text"><![CDATA[<%#Eval("name")%>]]> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></p>
</a>
</div>
 
                                        <div class="modal fade <%#Eval(" youruniqueid=")%>" id="editmember" role="dialog">
    <div class="modal-dialog">
    
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">×</button>
          <h4 class="modal-title"><![CDATA[<%#Eval("name")%>]]> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></h4>
        </div>


</div></div></div></div></itemtemplate>


这篇关于如何在按钮和模态上重复数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆