我正在尝试拥有一个 RTE 实例并将其重用于页面上需要富文本编辑的所有控件。我有两个文本区域,当我专注于其中一个文本区域时,我想打开模态对话框并传递选定的节点引用。
示例位于https://gist.github.com/945183
打开模态对话框很简单,但如何传递参考?
谢谢Binesh Gummadi
我正在尝试拥有一个 RTE 实例并将其重用于页面上需要富文本编辑的所有控件。我有两个文本区域,当我专注于其中一个文本区域时,我想打开模态对话框并传递选定的节点引用。
示例位于https://gist.github.com/945183
打开模态对话框很简单,但如何传递参考?
谢谢Binesh Gummadi
正如您所做的那样,将指向要编辑的节点的指针作为 XPath 表达式传递是一个不错的方法。我更新了您链接到的代码:我让它变得更简单,让它工作,并将结果粘贴在下面。
或者,您可以传递要编辑的控件的 ID。然后在对话框中,将其存储在一个实例中,并用于xxforms:binding()
查找绑定到该控件的节点。
<xhtml:html xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:f="http://orbeon.org/oxf/xml/formatting" xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:widget="http://orbeon.org/oxf/xml/widget"
xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:xbl="http://www.w3.org/ns/xbl" xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
<xhtml:head>
<xforms:model id="main"
xxforms:session-heartbeat="true"
xxforms:show-error-dialog="true">
<xforms:instance id="instance">
<dynamic>
<textarea1>Area1</textarea1>
<textarea2>Area2</textarea2>
<selectedNode/>
</dynamic>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body class="body">
<xforms:input ref="textarea1">
<xforms:label>Text Area 1</xforms:label>
</xforms:input>
<fr:button>
<xforms:label>Edit</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="selectedNode" value="context()/textarea1/saxon:path()"/>
<xxforms:show dialog="hello-dialog"/>
</xforms:action>
</fr:button>
<xhtml:br/>
<xforms:input ref="textarea2">
<xforms:label>Text Area 2</xforms:label>
</xforms:input>
<fr:button>
<xforms:label>Edit</xforms:label>
<xforms:action ev:event="DOMActivate">
<xforms:setvalue ref="selectedNode" value="context()/textarea2/saxon:path()"/>
<xxforms:show dialog="hello-dialog"/>
</xforms:action>
</fr:button>
<xxforms:dialog id="hello-dialog">
<xhtml:div>
<xforms:textarea mediatype="text/html"
ref="if (selectedNode != '') then saxon:evaluate(selectedNode) else ()"/>
</xhtml:div>
</xxforms:dialog>
</xhtml:body>
</xhtml:html>