Page 1 of 1

How to use plugins.ngclientutils.addClassToDOMElement

PostPosted: Thu Mar 18, 2021 10:08 am
by Juan Etec
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

Re: How to use plugins.ngclientutils.addClassToDOMElement

PostPosted: Fri Mar 19, 2021 12:42 am
by mboegem
Not sure, but shouldn't you also specify the element itself to have a fully qualified selector?
Like this:

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

Re: How to use plugins.ngclientutils.addClassToDOMElement

PostPosted: Sat Mar 20, 2021 10:58 am
by Juan Etec
Hi Marc, thanks for your reply.

It works in those cases:
Code: Select all
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

Re: How to use plugins.ngclientutils.addClassToDOMElement

PostPosted: Mon Mar 22, 2021 10:24 pm
by mboegem
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.

Re: How to use plugins.ngclientutils.addClassToDOMElement

PostPosted: Thu Mar 25, 2021 9:24 am
by paronne
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

Code: Select all
containers.myContainer.addStyleClasses(classes)


Regards,
Paolo