Hello,
I'm including a piece of JavaScript in the script and want to apply it to the container.
I'm making a "card" class for the container specifically for this, and I want to include the JavaScript source code in the HTML.
I want to provide the name of the class I built for the container as well as the src of that JavaScript in HTML.
How do I achieve this?
Hi @Nihhhil,
First, I'd strongly suggest you don't use as simple and common name as "card" for your class, it might be already in use by OutSystems UI (I know it was in the past, not sure if it still is). a class name like "vanilla-card" or "custom-vanilla-card" or any other less likely to exist name would be a better choice when you don't want to apply any existing style to your container.
Regarding adding JavaScript libraries to Reactive Web/Mobile OutSystems applications, the recommendation is you don't add links to external libraries directly and instead include the resources in your modules (although depending on your particular needs there may be other, more suitable alternatives). In any case, this post explains several approaches (make sure you go through the whole thread).
Finally, regarding your init(...) method call, off the top of my head, I would create an event handler for the OnReady screen event, and add a JavaScript node to its action flow where I'd use that JavaScript code. The JavaScript tool would need an input parameter (let's say it's called, for instance, Classname). In the Javascript snippet you shared, instead of ".your-element" you would instead use "." + $parameters.Classname.
init(...)
Classname
".your-element"
"." + $parameters.Classname
Hope this helps!
I actually didn't understand it. How do I apply the entire JS to the container I make in Outsystems?