Passing parameter to a function for onclick in an XSLT RSS

Scenario:

I have a link in a xslt file and some javascript methods in another file. When I click on the link, the javascript method invokes. I need to pass in a xsl value to the js method. OK, this sounds really confusing. Here is some code:

In the xsl file:

<a href=”#” onclick=”javascript:portal_openDispCalModalDialog(‘@xslparameter’)”>

<xsl:value-of select=”@Title” />

</a>

In the js file:

function portal_openDispCalModalDialog(id){

var options = {url:”list/DispForm.aspx?ID=”+id+”&IsDlg=1“,

dialogReturnValueCallback: CalDialogCallback

};

SP.UI.ModalDialog.showModalDialog(options);     }

Solution:

I needed to build my onclick as an attribute and then add the data inside it.

<a href=”#”>
<xsl:attribute name=”onclick”>
javascript:portal_openDispCalModalDialog(‘<xsl:value-of select=”@ID”/>’)
</xsl:attribute>
<xsl:value-of select=”@Title” />

</a>

 

Reference:

http://forums.asp.net/t/1498719.aspx/1

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s