i'm trying to display qtip2 for certain xpage Components. To make it generic, i have created a custom control which has (fieldID & componentID as custom properties). i have a view which has all fieldID's and associated help text for each id ( which is unique)

My problem is that i'm unable to call a SSJS function from CSJS with input parameters. Please see my code below. if i hardcode fieldID (getFieldHelp('"+fieldID+"')) everything works fine but when i pass variable it will return null value. Any help will be greatly appreciated. thanks in advance.

script block

    <xp:scriptBlock id="scriptBlock2"
    value="var fieldID=#{compositeData.fieldID};var componentID=#{compositeData.componentID};">
</xp:scriptBlock>

on client load event

   alert(componentID+"~~~~~~~~~~~"+fieldID)
   var helpContent="#{javascript:getFieldHelp('"+fieldID+"')}"
   alert(helpContent)
    $(document).ready(function()
    {
     x$("#{id:link_Test}").qtip({           
     //x$(compid).qtip({
         content: "helpContent",        
         style: 'qtip-tipsy qtip-shadow'

      });


    });
有帮助吗?

解决方案

This will not work. If you want to send a ClientSide variable 'fieldID' to a SSJS (getFieldHelp) you have to use something like the ExecuteOnServer function from Jeremy Hodge. because you have to POST this variable to the Server.

But why dont you use:

var helpContent ="#{javascript:getFieldHelp(compositeData.fieldID)}"

assuming that getFieldHelp is a SSJS function and both code snippets are in the same component. =) (maby you have to Change the # to $ to get the compositeData.)

update: I did some testing on getting the compositeData.FieldID in an CSJS onClientLoad event. What i came up with is this:

<xp:scriptBlock>
    <xp:this.value><![CDATA[XSP.addOnLoad(function(){
            alert("#{javascript:return compositeData.fieldId}");
            });]]></xp:this.value>
</xp:scriptBlock>

I use the XSP.addOnLoad() to execute the CSJS (onClientLoad) and inside the xp:scriptBlock i can pass the compositeData to the client side.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top