删除最后一次重复节点后无法插入

时间:2015-02-02 08:38:06

标签: xforms xsltforms

问题是,在我删除重复添加按钮中唯一剩下的行后,没有longers工作。

用额外的东西填充我的帖子以便接受问题

<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>

1 个答案:

答案 0 :(得分:1)

您有两种选择:

  1. 仅剩下一个项目时禁用“删除”按钮。 XForms Wikibook展示了如何:http://en.wikibooks.org/wiki/XForms/Disable_Trigger
  2. 将行的原点设置为不同的实例,而不是重复的最后一行。阅读本文,了解如何:http://en.wikibooks.org/wiki/XForms/Insert_with_Origin
  3. HTH!