删除最后一个重复节点后无法插入
Can't insert after last repeat node deleted
问题是,在我删除重复中唯一剩下的行后,“添加”按钮不再有效。
用额外的东西填充我的 post 以便问题被接受
<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Movie Review Selector</title>
<model xmlns="http://www.w3.org/2002/xforms">
<instance id="movies">
<movies xmlns="">
<movie id=""></movie>
</movies>
</instance>
<submission id="save" action="echo.xq" method="post" includenamespaceprefixes="" serialization="application/xml" ref="instance('movies')"/>
</submission>
</model>
</head>
<body>
<group xmlns="http://www.w3.org/2002/xforms" ref="instance('movies')">
<repeat nodeset="movie" id="idx">
<input ref="@id">
<label>Movie Id</label>
</input>
<trigger>
<label>Delete</label>
<delete nodeset="." ev:event="DOMActivate"></delete>
</trigger>
</repeat>
<trigger>
<label>Add</label>
<action ev:event="DOMActivate">
<insert nodeset="movie"></insert>
<setvalue ref="movie[last()]/@id" value=""></setvalue>
</action>
</trigger>
<submit submission="save">
<label>Submit</label>
</submit>
</group>
</body>
</html>
您有两个选择:
- 当只剩下一个项目时禁用删除按钮。 XForms Wikibook 展示了如何:http://en.wikibooks.org/wiki/XForms/Disable_Trigger
- 将行的起点设置为不同的实例,而不是重复的最后一行。阅读这篇文章以了解如何:http://en.wikibooks.org/wiki/XForms/Insert_with_Origin
HTH!
问题是,在我删除重复中唯一剩下的行后,“添加”按钮不再有效。
用额外的东西填充我的 post 以便问题被接受
<html xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xf="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Movie Review Selector</title>
<model xmlns="http://www.w3.org/2002/xforms">
<instance id="movies">
<movies xmlns="">
<movie id=""></movie>
</movies>
</instance>
<submission id="save" action="echo.xq" method="post" includenamespaceprefixes="" serialization="application/xml" ref="instance('movies')"/>
</submission>
</model>
</head>
<body>
<group xmlns="http://www.w3.org/2002/xforms" ref="instance('movies')">
<repeat nodeset="movie" id="idx">
<input ref="@id">
<label>Movie Id</label>
</input>
<trigger>
<label>Delete</label>
<delete nodeset="." ev:event="DOMActivate"></delete>
</trigger>
</repeat>
<trigger>
<label>Add</label>
<action ev:event="DOMActivate">
<insert nodeset="movie"></insert>
<setvalue ref="movie[last()]/@id" value=""></setvalue>
</action>
</trigger>
<submit submission="save">
<label>Submit</label>
</submit>
</group>
</body>
</html>
您有两个选择:
- 当只剩下一个项目时禁用删除按钮。 XForms Wikibook 展示了如何:http://en.wikibooks.org/wiki/XForms/Disable_Trigger
- 将行的起点设置为不同的实例,而不是重复的最后一行。阅读这篇文章以了解如何:http://en.wikibooks.org/wiki/XForms/Insert_with_Origin
HTH!