1

我正在创建一个 XSL 页面,我想在其中调用模式弹出窗口。下面是我的 XSL 文件的一部分:

   <xsl:if test="(/ShoppingBag/Multibuy/Discount) &gt; 0">
       <tr>
         <td class="sbTotalsColLeft saving">
           DiscountDetails
         </td>
         <td class="sbTotalsColRight">
       </td>
     </tr>
   </xsl:if>

我想要做的是当客户点击 DiscountDetails 我想显示一个带有以下信息的模式弹出窗口

   <table class="tbpromotionTypes">
     <xsl:for-each select="/ShoppingBag/MultibuyDiscountedPromotionTypes/PromotionType">
       <tr>
         <td class="ptLeft ">
           <xsl:value-of select ="./PromotionHeading"/>
         </td>
         <td class="ptRight">
           <xsl:value-of select="./DiscountedPrice"/>
         </td>
       </tr>
     </xsl:for-each>
   </table>
4

2 回答 2

0

XSLT 没有弹出窗口或点击的概念。

您可以使用xsl:messsage将文本记录到控制台。

您可以根据需要将 XML 转换为 HTML,包括 JavaScript,以创建一个以模式对话框和单击为可操作概念的页面。

对于此输入示例文件:

<?xml version="1.0" encoding="UTF-8"?>
<ShoppingBag>
  <MultibuyDiscountedPromotionTypes>
    <PromotionType>
      <PromotionHeading>Bread</PromotionHeading>
      <DiscountedPrice>$1</DiscountedPrice>
    </PromotionType>
    <PromotionType>
      <PromotionHeading>Eggs</PromotionHeading>
      <DiscountedPrice>$2</DiscountedPrice>
    </PromotionType>
    <PromotionType>
      <PromotionHeading>Milk</PromotionHeading>
      <DiscountedPrice>$2</DiscountedPrice>
    </PromotionType>
  </MultibuyDiscountedPromotionTypes>
</ShoppingBag>

这个 XSLT 脚本:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes"/>
  <xsl:template match="/">
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <title>jQuery UI Dialog - Default functionality</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <link rel="stylesheet" href="/resources/demos/style.css" />
        <script>
          $(function() {
            $( "#dialog" ).dialog({autoopen: false});
            $( "#dialog" ).dialog("close");
          });
          $(document).ready(function() {
            $('#discountDetailsId').click(function() {
              $( "#dialog" ).dialog({ modal: true });
            });
          });
        </script>
      </head>
      <body>
        <table>
          <tr>
            <td id="discountDetailsId">DiscountDetails</td>
          </tr>
        </table>
        <div id="dialog" title="Discount Details">
          <table class="tbpromotionTypes">
            <xsl:for-each select="/ShoppingBag/MultibuyDiscountedPromotionTypes/PromotionType">
              <tr>
                <td class="ptLeft ">
                  <xsl:value-of select ="./PromotionHeading"/>
                </td>
                <td class="ptRight">
                  <xsl:value-of select="./DiscountedPrice"/>
                </td>
              </tr>
            </xsl:for-each>
          </table>
        </div>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

生成此 HTML 文件 ( jsfiddle.net ):

<html lang="en">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta charset="utf-8">
      <title>jQuery UI Dialog - Default functionality</title>
      <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"><script src="http://code.jquery.com/jquery-1.9.1.js"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script><link rel="stylesheet" href="/resources/demos/style.css"><script>
          $(function() {
            $( "#dialog" ).dialog({autoopen: false});
            $( "#dialog" ).dialog("close");
          });
          $(document).ready(function() {
            $('#discountDetailsId').click(function() {
              $( "#dialog" ).dialog({ modal: true });
            });
          });
        </script></head>
   <body>
      <table>
         <tr>
            <td id="discountDetailsId">DiscountDetails</td>
         </tr>
      </table>
      <div id="dialog" title="Discount Details">
         <table class="tbpromotionTypes">
            <tr>
               <td class="ptLeft ">Bread</td>
               <td class="ptRight">$1</td>
            </tr>
            <tr>
               <td class="ptLeft ">Eggs</td>
               <td class="ptRight">$2</td>
            </tr>
            <tr>
               <td class="ptLeft ">Milk</td>
               <td class="ptRight">$2</td>
            </tr>
         </table>
      </div>
   </body>
</html>

这样,当您按要求单击 DiscountDetails 时,会显示一个模式对话框。

在此处输入图像描述

于 2013-09-25T15:22:18.377 回答
-1

建议:使用 td classes "sbTotalsColLeft" OR "saving" 和 JQuery 来显示模型弹出窗口

$(".sbTotalsColLeft").Click(...... modal popup code here ....);

参考:http: //jqueryui.com/dialog/

于 2013-09-25T15:29:46.987 回答