How to use plugins.ngclientutils.addClassToDOMElement

Hi,
I try to use plugins.ngclientutils.addClassToDOMElement(jQuerySelector,className) but I don’t know how.

I try:

  • plugins.ngclientutils.addClassToDOMElement(“:contains(‘unique_name’)”,‘hidden-md hidden-lg’);
  • plugins.ngclientutils.addClassToDOMElement(“[svy-name=‘unique_name’]”,‘hidden-md hidden-lg’);

Un Saludo

Not sure, but shouldn’t you also specify the element itself to have a fully qualified selector?
Like this:

plugins.ngclientutils.addClassToDOMElement("div:contains('unique_name')",'hidden-md hidden-lg');
plugins.ngclientutils.addClassToDOMElement("div[svy-name='unique_name']",'hidden-md hidden-lg');

Hi Marc, thanks for your reply.

It works in those cases:

plugins.ngclientutils.addClassToDOMElement('div[svy-name="unique_name"]','hola');
plugins.ngclientutils.addClassToDOMElement('[svy-name="unique_name"]','hola2');

I put it in the onShow process and it does not work, but if I put it in another process like onfocusgain or onrecordselection it works.
Is there any trick to make it works after the onShow?

Thanks

Hi Juan,

the addClassToDOMElement function is really meant to be used to add non-peristent classes to a DOM element to achieve really dynamic behaviour.
At the time of execution of the onShow, the page is not fully loaded yet so any change to the page generated by Servoy will be neglected or not even possible, because the DOM element does not yet exist.

Can you please describe/post images on what you are trying to do here?
I don’t think you are on the correct path to achieve what you want.

Hi Juan,

i assume your form is a Responsive Form.
With the latests versions of Servoy is possible to add/remove styleClass to Layout Containers such as div etc…
You can give a name to the container e.g. ‘myContainer’.
You can then add/remove styleClass to the container with

containers.myContainer.addStyleClasses(classes)

Regards,
Paolo