How to use plugins.ngclientutils.addClassToDOMElement

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

How to use plugins.ngclientutils.addClassToDOMElement

Postby Juan Etec » Thu Mar 18, 2021 10:08 am

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
Un Saludo

Juan Ramírez
Juan Etec
 
Posts: 59
Joined: Mon Apr 20, 2009 8:23 pm
Location: Gran Canaria - Spain

Re: How to use plugins.ngclientutils.addClassToDOMElement

Postby mboegem » Fri Mar 19, 2021 12:42 am

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');
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1574
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to use plugins.ngclientutils.addClassToDOMElement

Postby Juan Etec » Sat Mar 20, 2021 10:58 am

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
Un Saludo

Juan Ramírez
Juan Etec
 
Posts: 59
Joined: Mon Apr 20, 2009 8:23 pm
Location: Gran Canaria - Spain

Re: How to use plugins.ngclientutils.addClassToDOMElement

Postby mboegem » Mon Mar 22, 2021 10:24 pm

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.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1574
Joined: Sun Oct 14, 2007 1:34 pm
Location: Amsterdam

Re: How to use plugins.ngclientutils.addClassToDOMElement

Postby paronne » Thu Mar 25, 2021 9:24 am

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
paronne
 
Posts: 174
Joined: Fri Nov 02, 2012 3:21 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 7 guests

cron