I am trying to develop a plugin for jira and I’m having issues with jquery. I am pretty sure that its already part of the framework and all i need to do is include it but nothing seems to be working.
I have tried putting this in my atlassian-plugin.xml file
<web-resource key="jquery" name="jquery" >
<dependency>jira.webresources:jira-global</dependency>
<resource type="download" name="jquery.js" location="/includes/javascript/jquery.js" />
</web-resource>
I have tried it without the dependency as well
I have tried putting #requireResource("jira.webresources:jira-global") in my velocity template and that doesnt work either. THis is my js in my input.vm file
<script type="text/javascript">
jQuery(function($) {
$('.questions').hide();
});
</script>
Everything I seem to do just results in the Uncaught ReferenceError: jQuery is not defined
at a bit of a loose end now not really sure what to try next!
Take a look at the JIRA Subversion plugin for an example of how their resources get defined and included. It’s fiddly but it does work. The main documentation for this is at http://confluence.atlassian.com/display/PLUGINFRAMEWORK/Web+Resource+Plugin+Module
Main page for the plugin:
https://studio.plugins.atlassian.com/wiki/display/SVN/Subversion+JIRA+plugin
The main plugin config file at
https://studio.plugins.atlassian.com/svn/SVN/tags/atlassian-jira-subversion-plugin-0.10.5.4_01/src/main/resources/atlassian-plugin.xml
has a web-resource element defined that says it depends on jira.webresources which is where jquery comes from in JIRA:
jira.webresources:jira-global
and then this resource is loaded by https://studio.plugins.atlassian.com/svn/SVN/tags/atlassian-jira-subversion-plugin-0.10.5.4_01/src/main/java/com/atlassian/jira/plugin/ext/subversion/issuetabpanels/changes/SubversionRevisionsTabPanel.java
where it says
webResourceManager.requireResource(“com.atlassian.jira.plugin.ext.subversion:subversion-resource-js”);
The string in this call is crucial – it must be the “key” attribute of the top-level atlassian-plugin element plus a colon plus the “key” attribute of the resource element in atlassian-plugin.xml
HTH,
~Matt