【发布时间】:2015-03-19 00:10:19
【问题描述】:
我正在尝试通过使用不同的数据节点调用子表单来重用它,例如通过单击更改 xpath 表达式的触发器,然后加载子表单。
为此,我创建了一个绑定元素,但无法使其动态更改。我知道如何更改实例节点的值,所以我让我的绑定元素指向一个节点,但它不起作用。像这样的:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<xf:model xmlns="">
<xf:instance>
<tmp>
<configuration uri="/tmp/props"/>
<props>
<prop id="demo id 1" value="demo value1"/>
<prop id="demo id 2" value="demo value2"/>
</props>
</tmp>
</xf:instance>
<xf:bind id="dynamicNodeset" nodeset="string(/tmp/configuration/@uri)"/>
</xf:model>
</head>
<body>
<xf:repeat bind="dynamicNodeset">
<xf:output ref="prop/@id"/>
<xf:input ref="prop/@value" class="xforms-value"/>
</xf:repeat>
</body>
</html>
我也试过了,但没有成功:
<xf:bind id="dynamicNodeset" nodeset="/tmp/configuration/@uri[string()]"/>
Any idea how can I achieve this?
也可以通过 Js:
function changeBinding(modelId, bindId, newNodeset){
var model = document.getElementById(modelId).xfElement;
window.XsltForms_globals.openAction("XsltForms_change");
model.binds[0].nodeset = newNodeset;
model.setRebuilded(true);
model.addChange(bind);
window.XsltForms_globals.addChange(model);
window.XsltForms_globals.closeAction("XsltForms_change");
window.XsltForms_globals.refresh();
}
提前致谢。
【问题讨论】: