开发者

Sharepoint list xsl:merging javascript

开发者 https://www.devze.com 2023-02-28 17:04 出处:网络
Banging my head against the wall..... I have a SP list that uses an开发者_开发技巧 ajax script to pull different content into a page on click. I want the site owner to be able to enter a value in the

Banging my head against the wall..... I have a SP list that uses an开发者_开发技巧 ajax script to pull different content into a page on click. I want the site owner to be able to enter a value in the list to determine which content is called up when the page opens. The xsl:

<xsl:for-each select="//Data/Row">
    <a>
        <xsl:attribute name="href">javascript:ajaxpage('<xsl:value-ofselect="./@Target_x0020_page"/>','<xsl:value-of select="./@Target_x0020_div"/>');</xsl:attribute>
        <xsl:value-of select="./@Category"/>
    </a>
</xsl:for-each>

JS to open default content:

ajaxpage('2minxcat2.aspx' , 'index')

I've tried an xsl:if but it gets ignored. Any help appreciated.

Clarification; @CBono Sorry-the js is called with a link and works fine. This is an Office Live Small Business site-the xml is auto generated off the list and the xsl called in with a link. I'm trying to include this additional js snippet in the xsl so the owner can change which ajax content gets called in when the page opens by simply making a change in the list:

<script type="text/javascript"> ajaxpage('contenturlhere' , 'targetdiv') </script>

I've tried adding this:

 <xsl:if test="Opening_x0020_category = 1"><script type="text/javascript">ajaxpage('<xsl:value-of select="./@Target_x0020_page"/>

','')

But nothing gets outputted. It works as expected when the javascript above is inserted outside of the xsl. The logic I want is "If one of the list items has a '1' in a specified field, insert this content in this div when the page opens".

XML: Link


Have you tried escaping the single quotes inside your call to ajaxpage?

<script type="text/javascript">ajaxpage(&apos;<xsl:value-of select="./@Target_x0020_page"/>&apos;, &apos;<xsl:value-of select="./@Target_x0020_div"/>&apos;);</script>

Update: Looking at the XML source, it appears your xsl:if statement is testing an attribute of the current node. I think it should read:

<xsl:if test="@Opening_x0020_category = 1">
     <!-- your_output -->
</xsl:if>


I just rebuilt it line by line and it worked. The problem was the js not the xsl. Somehow the js was getting broken up after I entered it. When I made sure it was on one line, it worked. My own dumb fault. Thank you for your help.

0

精彩评论

暂无评论...
验证码 换一张
取 消