Disable in AB enable in JS


Ava Rashidi

Hi David,

I have 2 questions:

1

I have the problem with show/hide and disable/enable with AB and JS,

when a control disabled with AB I can not enable that with JS, Actually if I disable a control with AB I should enable it with AB(didn't work with JS) or vice versa.

This is also true for show/hide.

How can I use both of them together?

2

how can disable radio button with this cod?

Loop "1" "5" "[A]"

StartJS

var bb= ['Radio' + window.App.RootScope.A];

$(bb).prop( "disabled", true );

EndJS

EndLoop

thanks,


DecSoft

Hello Ava,

For the first question, certainly we can use AB actions or pure Javascript without problems. You don't refer how you try to disable / enable a control using Javascript, but, probably the mistake is that you must use a non empty string (preferible "true") to disable an object (or to hide it) and an empty string, in order to enable / show it.

Doing the above the below code do exactly the same thing:

About the second question, we can use the below code to do what you wanted with the specified four buttons:

You can take a look at a sample app that I prepare for you, copy the below code and save it in a file like "MyApp.ab", open it with DecSoft App Builder and run the app.

P.S. Please, don't hesitate to open different threads to ask different questions, so the forum is more or less well ordered and searchable.

P.S.2. By my mistake I use Push buttons controls when reply to your Radio buttons question: in fact it's the same code, that is, that code must work if you change "Button" for "RadioButton" and you have the right "RadioButtonN" controls in your app's view.



Ava Rashidi

Hello David

sorry for my thread with different question

please test this code:

Loop "1" "2" "[A]"

StartJS

window.App.RootScope['Radio' + window.App.RootScope.A].Disabled = 'true';

EndJS

EndLoop

StartJS

$('#Radio1').on('touchstart click', function (event) {

if (event.type == "touchstart") $(this).off('click');

if (Radio1.disabled) {

alert("disable");

}

else {

alert("enable");

}

});

EndJS

we see this alert: enable, In the event that the radio button is disable.

Thank you for all your assistance.


DecSoft

Hello Ava,

I think you can't use something like "Radio1.disabled" for the condition. Probably "Radio.disabled" is not defined, for that reason the "enable" alert appear, because the condition is not "true". I think the condition must be something like this:

P.S. Please, use the "code" HTML tag to post code: it's better for you (less paragraphs) and better for all (more readable).



Ava Rashidi

Yes, my problem has been resolved

Thank you very much; your support is greatly appreciated ≧°◡°≦

DecSoft

Glad to know that you got it, Ava! :-)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.