Create a simple modal pop-up window in XSLT

不羁的心 提交于 2019-12-19 21:47:34

问题


I am building a style sheet that has a few Members in the table. What I want is when I click on each Member a pop-up modal window to open with that Member's data which is in the XML file (I can use Member ID for reference). I tried to use fancybox (http://fancybox.net/) but the problem with that is, these Members are populated dynamically from the XML and when I click on one Member it opens pop-up with data from some other Member.

XML

<Members>
<Member Name = “John Smith” MemberNumber = “JS001” DateofBirth = “09/01/1978” Gender = “Male”/>
<Member Name = “Andy Rodrigues” ” MemberNumber = “AR001” DateofBirth = “05/01/1970” Gender = “Male”/>
<Member Name = “Julie Dean” ” MemberNumber = “JD001”  DateofBirth = “05/01/1970” Gender = “Male”/>
</Members>

**Stylesheet**
Member Name             Member Number   
[John Smith][1]         JS001
[Andy Rodriguez][1]     AR001
[Julie Dean][1]         JD001

**Pop-up**
Member            John Smith
Date of Birth     09/01/1978
Gender            Male

Member Names on the stylesheet are links that should open popups with Member information like date of birth and gender.

My code sample using FancyBox:

 <xsl:for-each select="Members/Member">
    <tr>
      <td>

        <div class="indicator bck-belize-hole brd-peter-river">
          <xsl:element name="a">
            <xsl:attribute name="href">#inline_DTRXMLInfo</xsl:attribute>
            <xsl:attribute name="class">various moreinfo whiteicon</xsl:attribute>

            <xsl:value-of select="@Name"/>
          </xsl:element>

        </div>
        <xsl:value-of select="@Name"/>

      </td>
      <td >
        <font face="Arial" size="2" color="black">
          <b>
            <xsl:value-of select="@MemberNumber"/>
          </b>
        </font>
      </td>
    </tr>
    </xsl:for-each>
  <div class="fancynone">

  <div id="inline_DTRXMLInfo" class="fancysize">
    <xsl:call-template name="DTRXMLInfo">

      <xsl:with-param name="Date Of Birth" select="DateofBirth"></xsl:with-param>

    </xsl:call-template>
  </div>

回答1:


Solution:

Since the Members are added to the stylesheet on the fly, we have to give <div> inline_DTRXMLInfo a unique ID which can be achived by appending MemberNumber to the <div> ID.

Code:

 <xsl:attribute name="href">#inline_DTRXMLInfo_<xsl:value-of select="@MemberNumber"/></xsl:attribute>

<div id="inline_DTRXMLInfo_{$MemberNumber}" class="fancysize">
    <xsl:call-template name="DTRXMLInfo">

      <xsl:with-param name="Date Of Birth" select="DateofBirth"></xsl:with-param>

    </xsl:call-template>
  </div>


来源:https://stackoverflow.com/questions/34534759/create-a-simple-modal-pop-up-window-in-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!