Show and hide elements in a Velocity Template using a button

matias November 27, 2017

Hi everyone, i'm new on creating velocities templates, and I wonder how to hide and show a table or any html element using a button, if it's clicked the element is shown, clicked again and this should be hidden, I've seen a similar question here but it didn't involved an event trigger by an action like clicking a button, thanks!

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 27, 2017

Hello,

If you define your own velocity template then you should use Jquery to hide an element. Something like AJS.$("element").hide(). Have a look at jquery documentation.

matias November 28, 2017

So I can use jquery with my template so I could use something like

<button onClick="AJS.$("element").hide()">

but my question is this, if I'm gonna use jqueryl for this, besides adding the library in the head should I need more configuration to make jquery works on my template? I ask this because I tried doing this with javascript but the templates shows only velocity sintaxis and ignores completely my js.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2017

Where do you change your velocity file? Is it a plugin you are developing?

matias November 28, 2017

I'm on the server using java(theres where I change it), then I use a server method to send that template to be shown on an email.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2017

Do you mean that you change velocity templates for email? And you want Javascrit to work in outlook or something like this?

matias November 28, 2017

The template is on the server with the rest of my classes, then is sent as one more parameter of the server method, I guess this compiles with the rest of the app if you mean change by compile.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2017

If you develop a Jira plugin, then JQuery must be available there. But I really do not understand what you develop. 

matias November 28, 2017

Would you give me an example of a template using jquery, it'd be really helpfull, thanks

Suggest an answer

Log in or Sign up to answer