osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Deactivate a component instead of hide

Hello,

I found many examples on how to hide/show a component, but how about deactivate? I am using a YES/NO toggle control and when it is set to NO, I want to make other controls on the page visible but not editable.

Can you give me some example code?

Thanks.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Deactivate a component instead of hide

Some basic HTML elements such as input have a disabled attribute. You can check if the component you need to "disable" has such attribute. You can also check readonly property.

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Deactivate a component instead of hide

So for example, can i disable all the controls in a grid or do I have to do one at a time? and if I use the readonly attribute, how would that be coded?

Appery("componentName").readonly();

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Deactivate a component instead of hide

I don't believe that's the right call. You would need to check jQueryMobile docs for the correct API.

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Deactivate a component instead of hide

Just a little more direction please. I'm a newbie at mobile apps.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Deactivate a component instead of hide

Can you show us what component you are trying to make read only and what you tried?

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Deactivate a component instead of hide

I have a check box control with 7 checkboxes (one for each day of the week). I want to programatically make the control ReadOnly when the Toggle control is set to NO.

if (Appery("OnOff1").val()=="off")
{
//make all Alarm1 elements gray and Uneditable
Appery("Alarm4DOW").readonly();
}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Deactivate a component instead of hide

Hello!
To make component (input, textarea, button, list) visible, but disabled you should add ui-disabled class for component:
preAppery("componentName").addClass("ui-disabled");/pre
to enabled it - delete this class
preAppery("componentName").removeClass("ui-disabled");/pre

osiris1@yahoo.com
Posts: 0
Joined: Mon Jun 10, 2013 5:34 pm

Deactivate a component instead of hide

Hi Marina,

This is my code on the PAGE SHOW event, but the code does not disable the checkbox group.

if (Appery("OnOff1").val()=="on")
{
//make all Alarm1 elements editable
Appery("OnOff1").val("on").refresh();
Appery("OnOff1").removeClass("ui-disabled");
}
else
{
//make all Alarm1 elements grey and Uneditable
Appery("OnOff1").addClass("ui-disabled");
}

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Deactivate a component instead of hide

Try this code:
codeif (Appery("OnOff1").val()=="on") {
Appery("CheckboxGroupName").removeClass("ui-disabled");
Appery("someOtherElementName").removeClass("ui-disabled");
} else {
//make all Alarm1 elements grey and Uneditable
Appery("CheckboxGroupName").addClass("ui-disabled");
Appery("someOtherElementName").addClass("ui-disabled");
}/code
where CheckboxGroupName, someOtherElementName - element's names which you want to be disabled/enabled (please note you need to add all elements which are going to be disabled/enabled, there are only two elements in example)

Return to “Issues”