How to import jQuery dynamically into Jira Plugin? (specifically, the Sticky Table Header jquery)

Hey guys, I'm still fairly new to plugin development and this is my first time using jQuery.

I am trying to use the Accessible Sticky Table Header Plugin - jQuery stickyTableHeader (located here: https://www.jqueryscript.net/table/Accessible-Sticky-Table-Header-Plugin-jQuery.html) in my jira plugin, but I'm having trouble with it.

I followed the steps starting from step 2, but it is not working. In the view.vm file, I included the following code (except without the first line of code because I heard jquery is included in jira?):

<script src="//code.jquery.com/jquery.min.js"></script>
<script src="jquery.stickyTableHeader.js"></script>

In step 3, it told me to wrap the html table into a div container. They had <div class="table-container">, but I had <div class="table-wrap">. I don't know if this would make a difference or not

Step 4 told me to initialize the plugin, though I was a bit confused with what it meant by that. All it did was provide this code:

$('.table-container').stickyTableHeader();

I copied it and made some changes to it so that it'd match whatever class I had put down for the <div> tag. I even tried changing the class of the <div> tag so that it would match the steps. No luck. It just showed up as plain text on my plugin page. I don't know if it might have been because I copied it into the first 2-3 lines of my code. Should it be placed at the end?

After that didn't work, I tried copying that jquery.stickyTableHeader.js file into the js folder of my plugin, and then edited the web-resources section of the atlassian-plugin.xml file to include it, but I received an error upon compiling.

I hope you guys can help me out a bit with this, thanks!

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

170 views 1 3
Join discussion

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