EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Aod47 on October 17, 2015, 03:21:48 PM



Title: How to load switchbutton with checked value from json file
Post by: Aod47 on October 17, 2015, 03:21:48 PM
Could you please show a demo? How to load switchbutton with checked value from json file into a form.


Thank you very much.


Title: Re: How to load switchbutton with checked value from json file
Post by: stworthy on October 17, 2015, 04:46:59 PM
Please refer to http://jsfiddle.net/mzs4kyzt/


Title: Re: How to load switchbutton with checked value from json file
Post by: Aod47 on October 17, 2015, 07:55:20 PM
Thank you, Sir.

If I understood right. Switch Button will display ON if load value equal default value.


Code:
<button id="b1">Load</button>
<button id="b2">Clear</button>

<form id="ff">
    <p><input name="t1" class="easyui-textbox"></input></p>
    <p>Option 1
    <input name="s1" class="easyui-switchbutton" value="1"></input>     
    </p>
    <p>Option 2
    <input name="s2" class="easyui-switchbutton" value="1"></input>     
    </p>
</form>

<script>
$('#b1').click(function(){
    $('#ff').form('load', {
        t1:'text1',
        s1: '1',
        s2: '0'
    });
});
$('#b2').click(function(){
    $('#ff').form('clear');
});
</script>