1

I'm using a DFWP and customising to send values to javascript function.

I've managed to pass certain types of variables from XSLT to Javascript using the below code.

<a><xsl:attribute name="href">#</xsl:attribute><xsl:attribute name="onClick">javascript:portal_openModalDialog("<xsl:value-of select='@ows_Title' />","<xsl:value-of select='@ows_ID' />")</xsl:attribute>test</a>

This works fine but when try to exchange ows_ID for ows_Description (Multiline field) nothing happens (function does not appear to work).

I tried escaping using disable-output-escaping but still nothing works.

When I print out to screen I can see the value of xsl:value-of select="@ows_Description" with and without the disable-output-escaping.

I've copied @ows_Description to a variable and then attempted to pass the variable instead but as previously the function doesnt work.

Finally I would also like to truncate the ows_Description.

UPDATE: Think it might help to show output of @ows_Description (without disable-output-escaping)

<div class="ExternalClassB01973441A78460F8B02CD3603EF4C07"><p>​<span class="st">The James Dyson <strong>Award</strong> is an international design <strong>award</strong> that celebrates, encourages and inspires the next generation of design engineers. The <strong>Award</strong> is open ...</span></p></div> 

Below is how it appears after changing the code as suggested (SPD has change automatically after save)

<a><xsl:attribute name="href">#</xsl:attribute><xsl:attribute name="onClick">javascript:portal_openModalDialog("<xsl:value-of select='@ows_Title' />","translate('<xsl:value-of select='@ows_Description' />&apos;,&apos;

','')") test

1 Answer 1

0

New line characters might be causing this problem. Try removing those character using translate function and then pass it to JavaScript.

Something like

javascript:portal_openModalDialog("<xsl:value-of select='@ows_Title' />","translate('<xsl:value-of select='@ows_Description' />','&#xD;&#xA;','')")
2
  • Tried the above line but SPD changes the last few characters to &apos; and same problem persists. Commented Nov 4, 2014 at 9:53
  • @user32056 can you update the question with how it now appear in SPD? Commented Nov 4, 2014 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.