unplugged / unplugged-controls

7 stars 9 forks source link

Mobile switch control #511

Closed MartinPerrie closed 10 years ago

MartinPerrie commented 10 years ago

The "FormsEditMode" XPage in the Sampler app gives the following as an example of a mobile switch control :-

<li>
    <xp:label value="Mobile Enabled" for="mobileenabled"></xp:label>
    <div class="switch">
        <xp:checkBox text="" id="mobileenabled"
            checkedValue="on" uncheckedValue="off"
            value="#{document2.mobileenabled}" required="false">
        </xp:checkBox>
    </div>

</li>

which is fine if using the default "on" and "off" values. But if you want to use alternate values (e.g. "1" and "0") then the checkedValue and uncheckedValue need to be specified as attributes so the code at the top of unp.SaveDocument can pick them up. E,g,

<li>
    <xp:label value="Mobile Enabled" for="mobileenabled"></xp:label>
    <div class="switch">
        <xp:checkBox text="" id="mobileenabled"
            value="#{document2.mobileenabled}" required="false">
            <xp:this.attrs>
                <xp:attr name="checkedValue"
                    value="1">
                </xp:attr>
                <xp:attr name="uncheckedValue"
                    value="0">
                </xp:attr>
            </xp:this.attrs>            
        </xp:checkBox>
    </div>

</li>
whitemx commented 10 years ago

I'll add this to the documentation.