How do you properly use JavaScript in Text Gadget?

Hey there,

 

I'm trying to add more content to my JIRA dashboard by using the HTML capabilities of the "Text Gadget". Things seem to run great the first time, but I get an "Unknown error occurred rendering this gadget" if I try to edit the gadget's content.

 

Here's the specific JS I'm adding:

<h3><div id=”milestone_countdown”></div> days left!</h3>

<script>
today=new Date();
var next_milestone=new Date(today.getFullYear(), 10, 12);
var one_day=1000*60*60*24;
document.getElementById("milestone_countdown").innerHTML = Math.ceil((next_milestone.getTime()-today.getTime())/(one_day));
</script>

 

And the error I'm getting when I inspect the element in the page:

Uncaught TypeError: Cannot set property 'innerHTML' of null
Error rendering gadget with id '15053': Cannot set property 'innerHTML' of null TypeError: Cannot set property 'innerHTML' of null

 

What am I doing wrong and how can I fix this?  Thanks!

0 answers

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

974 views 5 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot