Page 1 of 2

Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 3:03 pm
by osiris1@yahoo.com

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.


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 3:06 pm
by maxkatz

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.


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 3:11 pm
by osiris1@yahoo.com

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();


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 3:30 pm
by maxkatz

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


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 6:22 pm
by osiris1@yahoo.com

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


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 6:43 pm
by maxkatz

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


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 6:59 pm
by osiris1@yahoo.com

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();
}


Deactivate a component instead of hide

Posted: Thu Sep 19, 2013 7:12 pm
by Maryna Brodina

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


Deactivate a component instead of hide

Posted: Fri Sep 20, 2013 1:40 pm
by osiris1@yahoo.com

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");
}


Deactivate a component instead of hide

Posted: Fri Sep 20, 2013 5:04 pm
by Maryna Brodina

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)