EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Kot_dnz on March 05, 2018, 03:26:12 PM



Title: [RESOLVED] switchbutton readonly change style
Post by: Kot_dnz on March 05, 2018, 03:26:12 PM
Could you please help me and describe how can I able to change the style of switchbutton in readonly mode.

Switchbutton declared as:

<input class="easyui-switchbutton" value="1" name="hours_7" id="hours_7"
            data-options="onText:'Да',offText:'Нет'">

<style>
    .switchbutton-readonly {
        opacity: 0.5;
        filter: alpha(opacity=50);
    }
</style>

not working :(


Title: Re: switchbutton readonly change style
Post by: jarry on March 05, 2018, 08:06:35 PM
A readonly switchbutton should have the 'readonly' property set to true.
Code:
<input class="easyui-switchbutton" value="1" name="hours_7" id="hours_7" 
            data-options="onText:'Да',offText:'Нет',readonly:true">

<style>
    .switchbutton-readonly {
        opacity: 0.5;
        filter: alpha(opacity=50);
    }
</style>


Title: Re: switchbutton readonly change style
Post by: Kot_dnz on March 06, 2018, 07:07:19 AM
Thank you.
But this is working only with predefined swbutton.

What about dynamically changing?
Mb require to redrawing the form?

Example:
Code:
<body>

<input class="easyui-switchbutton" value="1" name="sb" id="sb">

<div style="margin:20px 0;">
    <a href="#" class="easyui-linkbutton" onclick="$('#sb').switchbutton('options').readonly=true">On RO</a>
    <a href="#" class="easyui-linkbutton" onclick="$('#sb').switchbutton('options').readonly=false">OFF RO</a>
</div>

<style>
    .switchbutton-readonly {
        opacity: 0.5;
        filter: alpha(opacity=50);
    }
</style>
</body>

And nothing.


Title: Re: switchbutton readonly change style
Post by: jarry on March 06, 2018, 11:47:07 PM
Call 'readonly' method to set its readonly state.
Code:
$('#sb').switchbutton('readonly');
$('#sb').switchbutton('readonly', false);


Title: Re: switchbutton readonly change style
Post by: Kot_dnz on March 07, 2018, 05:33:11 AM
Thank you!
Now all is working properly!