Show and hide elements in a Velocity Template using a button

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 Community Champion Nov 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.

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 Community Champion Nov 28, 2017

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

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.

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

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 Community Champion Nov 28, 2017

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

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
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #2: Let’s talk severity levels

Welcome to your weekly Jira Ops Early access program update, where we’re sharing news and updates on Jira Ops' progress as we work toward our 1.0 release. If you ever want to drop us feedback or idea...

25 views 0 0
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you