1

我在 8.5.3 中有以下代码

<xp:div>
    <xp:this.attrs>
          <xp:attr name="data-theme" value="#{javascript:compositeData.data_theme}" />
          <xp:attr name="data-position" value="#{javascript:compositeData.data_position}" />
          <xp:attr name="data-role" value="footer" /> 
    </xp:this.attrs> 
</xp:div>

工作正常。但是客户有 Domino 8.5.2。而且这个版本也不支持tagNameattr。我有计算的值attr

如何在类似的构造中使用compositeDate

<div data-position="#{javascript:compositeData.data-position}" ...

??

一种解决方法是使用计算文本

<xp:text escape="false" id="ctFooterDivStart">
    <xp:this.value><![CDATA[#{javascript:"<div data-theme='"+ compositeData.data_theme + "' data-position='" + compositeData.data_position + "' data-role='footer'>"}]]></xp:this.value>
</xp:text>

但这是丑陋的,难以阅读。

4

3 回答 3

1

The workaround so far is to write data_position instead of data-position in the source tab to make shure, designer creates the code without errors.

Next I have a small scriptblock on my page to replace all data_position with data-position

$(document).ready(function () {$('div[data_position ]').each(function(){
    $(this).attr('data-position ', $(this).attr('data_position ')); //does the switch
    $(this).removeAttr('data_position '); //clears out the old one
});});

Just a workaround ( idea ). Not checked, if this really is the best way in terms of performance. ...

于 2013-04-08T15:07:55.423 回答
1

为此使用主题怎么样?

<control>
    <name>div-data-theme</name>
    <property mode="override">
        <name>value</name>
        <value>${javascript:@Char(60) + "div data-theme='" + compositeData.data_theme + "' data-position='" + compositeData.data_position + "' data-role='footer'" + @Char(62) + @Char(60) + "/div" + @Char(62)}</value>
    </property>
    <property mode="override">
        <name>escape</name>
        <value>${javascript:false}</value>
    </property>
</control>

(@Char 是必需的,因为您不能在主题中使用括号并且 CDATA 不起作用)

在您的自定义控件中,您可以通过添加xp:text元素来使用它:

<xp:text themeId="div-data-theme">
</xp:text>

如果您不向xp:text组件添加 id,它将不会被 span 标签包围。

于 2013-04-09T12:10:49.140 回答
0

我现在决定使用计算文本。涉及的代码不多。所以代码仍然可读。这是可折叠集(手风琴)的示例

...
<xp:text escape="false">
    <xp:this.value><![CDATA[${javascript:var html = "<div " 
            html = html + "data-role='collapsible-set' " 
            html = html + "data-mini='" + compositeData.data_mini + "' "
            Html = html + "data-theme='" + compositeData.data_theme + "' " 
            html = html + "data-inset='" + compositeData.data_inset + "' "
            html = html + "data-iconpos='" + compositeData.data_iconpos + "' " 
            html = html + "data-content-theme='" + compositeData.data_content_theme + "' " 
            html = html + "data-collapsed-icon='" + compositeData.data_collapsed_icon + "' " 
            html = html + "data-expanded-icon='" + compositeData.data_expanded_icon + "'> " 
            return html}]]></xp:this.value>
</xp:text>
<xp:callback facetName="fctAccordion" />
<xp:text escape="false">
    <xp:this.value><![CDATA[${javascript:"</div> "}]]></xp:this.value>
</xp:text>

...

于 2013-04-10T12:27:31.877 回答