سؤال

is it possible to set data type for repeated elements? When I use bind all the elements in repeat use the same data node (have the same values). This problems doesn't appear when there are simple textfields in repeat (after adding more elements using insert, every element may have different values). In this code there is checkbox and button to add another checkboxes but when I add another element and change checkbox value all of them are changed.

<head>
    <xf:model>
        <xf:instance xmlns="">
            <ProcessData>
                <chck1s>
                    <chck1>true</chck1>
                </chck1s>
            </ProcessData>
        </xf:instance>
        <xf:bind nodeset="/ProcessData/chck1s/chck1" type="xs:boolean"/>        
    </xf:model>  
</head>
<body>
    <xf:group>
        <xf:repeat id="chck1s" nodeset="/ProcessData/chck1s/chck1">
            <xf:input ref="/ProcessData/chck1s/chck1">
                <xf:label>test checkbox1</xf:label>
            </xf:input>
        </xf:repeat>
        <xf:trigger>
            <xf:label>+</xf:label>
            <xf:action ev:event="DOMActivate">
                <xf:insert at="index('chck1s')" nodeset="/ProcessData/chck1s/chck1" position="after"/>
            </xf:action>
        </xf:trigger>
    </xf:group>
هل كانت مفيدة؟

المحلول

You should modify the input control within the repeat to access the current item instead of always the first one.

<xf:input ref=".">

-Alain

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top