Hello is there any solution to do a checkbox readonly and not disable ?
you can put [disabled] = “true” after fill the checkbox
[disabled] = “true” will apply his “grey css” that’s what I would like to avoid…
Have you already tried something like that?
HTML
<form id="aform" name="aform" method="POST">
<input name="chkBox_1" type="checkbox" checked value="1" readonly />
<br/>
<input name="chkBox_2" type="checkbox" value="1" />
<br/>
<input id="submitBttn" type="button" value="Submit">
</form>
CSS
input[type="checkbox"][readonly] {
pointer-events: none;
}
Will give a shot tomorrow
This may break in shadow dom (ionic 4)
Alternative, hacky, way would be to undo the user check action using ionChange event
ion-checkbox.checkbox-disabled {
opacity : 1;
}
I would suggest not doing this, because of the principle of least surprise. Users expect common controls to behave like they commonly do. Instead of a checkbox, how about using an icon set (I’m partial to Font Awesome, but I’m sure the Ionicons have some suitable options as well)? Choose a pair of icons that make sense for your app domain that would represent “on” and “off”, and switch between them depending on the state of the readonly boolean variable.