javascript - 在 XSLT 中使用带参数的 javascript

标签 javascript xslt

嗨,我正在尝试使用节点“Path”的值调用一个名为 bob 的 JavaScript 函数。 我在 XSLT 中尝试做的事情可能吗?谢谢。

<xsl:template match="/">
    <div id="subdirectory">
        <div style="height:30px;width:100%; float:left; padding-top:10px;">
            <xsl:for-each select="Reports/Folder">

                <xsl:variable name="varPath" select="Path"/>

                <input type='button' class="Folder" style="height:30px; float:left; margin-right:5px; margin-top:5px;" value="{Name}" onclick="this.disabled = true; bob("<xsl:value-of select="Path"/>");">
                    <xsl:attribute name="xml">
                        <xsl:value-of select="Xml"/>
                    </xsl:attribute>
                    <xsl:attribute name="data-path">
                        <xsl:value-of select="Path"/>
                    </xsl:attribute>
                    <xsl:attribute name="report-name">
                        <xsl:value-of select="Name"/>
                    </xsl:attribute>
                    <xsl:attribute name="directoriesDeep">
                        <xsl:value-of select="DirectoriesDeep"/>
                    </xsl:attribute>
                </input>
            </xsl:for-each>
        </div>
    </div>

最佳答案

最后解决了。

我将 onclick 事件作为一个属性,然后代码很乐意将 jscript 放在那里。

                    <xsl:variable name="varPath" select="Path"/>

                <input type='button' class="Folder" style="height:30px; float:left; margin-right:5px; margin-top:5px;" value="{Name}" onclick="this.disabled=true">
                    <xsl:attribute name="xml">
                        <xsl:value-of select="Xml"/>
                    </xsl:attribute>
                    <xsl:attribute name="data-path">
                        <xsl:value-of select="Path"/>
                    </xsl:attribute>
                    <xsl:attribute name="report-name">
                        <xsl:value-of select="Name"/>
                    </xsl:attribute>
                    <xsl:attribute name="directoriesDeep">
                        <xsl:value-of select="DirectoriesDeep"/>
                    </xsl:attribute>
                    <xsl:attribute name="onclick">
                        bob($varPath)
                    </xsl:attribute>                              
                </input>
            </xsl:for-each>

关于javascript - 在 XSLT 中使用带参数的 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17408142/

相关文章:

javascript - JavaScript 中的日期格式

javascript - 将 MVC 模型与 'contenteditable' 属性混合——是否可以以简单的方式将数据发送回服务器?

javascript - Ember.js Handlebars.helpers.collection 不工作

html - 在 HTML5 时代使用客户端 XSLT 转换

javascript - 使用 AJAX 加载的 XSLT,包含仅在 Firefox 中触发的 &lt;script&gt;

xml - 在 xslt 中显示变量的值

javascript - 如何在 DataTables 中搜索多个列?

javascript - 按升序和降序对多个数组键进行排序,带数字的字符串

xml - 从 xsd 架构引用 spring bean 值

templates - *和XSLT中的node()之间的区别