using js_addClass

using js_addClass

  

Hi,


How do I properly use js_addClass action. I tried to use it in a custom screen action. However the class is never added. Could this be because I have defined the class in the style propery of the input field I am trying to address?

I am trying to add the class to that field as to change the styling.

I know I can dot this also by creating a local variable with boolena value and then refresh the input field container so the calss is added by an if statement in the extended property, but I have quite a number of fields and it means creating lots of local variables when adding a class with js_addClass could be the cleaner solution.

Solution

Hi Edwin,

The Action js_addClass outputs a text parameter with the javascript that you need to run. But it does not run it.

Thus, to run it, you first call the js_addClass Action in your Screen Action and afterwards, in the same Screen Action, you can call the RunJavaScript Action (from HTTPRequestHandler Module) with the output of js_addClass as input of the RunJavaScriptAction. This will run the javascript to add the class to the element that you specified.

Tell me if this does not work for you.

Cheers,

José

Solution

It does not seem to work. I am using it on an input field. After doing what you said I refreshed the input field but the class is not added.

Hello Edwin,

You need to call the RunJavaScript after the ajax refresh node, or the class will be removed.

Cheers,
Eduardo Jauch

EDIT

The RunJavaScript will send the script back with the server answer to the browser, to be executed there. So, if you call first the RunHJavaScript and later the Ajax refresh, the browser will first apply the class and than render the input again, this time without the class recently added. 

The sequence you do things here is important.

Thanx for the replies. Got it working now.

Nice :)

Consider marking José's answer as correct, please. :)

Cheers,
Eduardo Jauch

EDIT

I was too fast, sorry ;)