How can i use resources in jira plugin ?

I want to use a js file in my plugin . so i add

<web-resource key="myresource" name="Myresource" >
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <dependency>jira.webresources:jira-global</dependency>
        <dependency>jira.webresources:autocomplete</dependency>
        <resource type="download" name="test.js" location="javascripts/test.js">
          <property key="content-type" value="text/javascript"/>
        </resource> 
        <context>page</context>
    </web-resource>

to the atlassian-plugin.xml . Then I use #requireResource("com.jira.plugin:myresource") in my gadget xml file . But it seems doesn't work . and test.js just includes alert("haha");

Does any one know how to add a external resource to the plugin ?? Thanks .

3 answers

1 accepted

This widget could not be displayed.

firstly,you ensure the prefix "com.jira.plugin" is the key of your plugin.

secondly,you try to modify the <context> to "<context>alt.general</context>"

this is my jira web-source's definition:

&lt;web-resource key="myWorklogResource" name="myWorklogResource" &gt;
    	&lt;description&gt;this web-resource is for creating or editing the work log about budget selector&lt;/description&gt;
    	&lt;dependency&gt;com.atlassian.auiplugin:ajs&lt;/dependency&gt;
        &lt;dependency&gt;com.atlassian.auiplugin:jquery&lt;/dependency&gt;
    	&lt;resource type="download" name="budgetselector.js" location="javascript/budgetselector.js"/&gt;
    	&lt;resource type="download" name="budgetselector.css" location="css/budgetselector.css"/&gt;
    	&lt;context&gt;atl.general&lt;/context&gt;
    &lt;/web-resource&gt;
and it works .
good luck

Thank you . It works for me , You help me a big favor .

Hi. I can't run the javascript too. I'm using JIRA 7.2 and I'm trying to create a page in the JIRA admin add-ons to keep some data using active objects, but for now I'm only want to understand how to execute the javascript.

 

&lt;web-resource key="asb-resources" name="asb Web Resources"&gt;  &lt;dependency&gt;com.atlassian.auiplugin:ajs&lt;/dependency&gt;  &lt;resource type="download" name="asb.css" location="/css/asb.css" /&gt;  &lt;resource type="download" name="asb.js" location="/js/asb.js" /&gt;  &lt;resource type="download" name="images/" location="/images" /&gt;  &lt;context&gt;atl.admin&lt;/context&gt; &lt;/web-resource&gt; &lt;web-section name="asbSettings" i18n-name-key="asb-admin-settings.name" key="asb-admin-settings" location="admin_plugins_menu" weight="1000"&gt;  &lt;description key="asb-admin-settings.description"&gt;Settings for asb plugins&lt;/description&gt;  &lt;label key="asb-admin-settings.label"&gt;asb Admin Settings&lt;/label&gt; &lt;/web-section&gt; &lt;web-item name="abLink" i18n-name-key="ab-link.name" key="ab-link" section="admin_plugins_menu/asb-admin-settings" weight="100"&gt;  &lt;description key="ab-link.description"&gt;Administration of connections with AB&lt;/description&gt;  &lt;label key="ab-link.label"&gt;AB Link&lt;/label&gt;  &lt;link linkId="ab-link-link"&gt;/secure/ListABLink!default.jspa&lt;/link&gt; &lt;/web-item&gt;

The link in the web-item send to a velocity template where I'm trying to create a pop-up when the user click in a button. I put some console.log and alert in the asb.js, but nothing happen.

Anyone know what is wrong here?

Thanks.

 

 

This widget could not be displayed.

Hi!

I learned that You have to use 

<meta name="decorator" content="atl.admin" />

within your .vm file to have JS loading and excuting.

every other one like

<meta name="decorator" content="atl.general" />

only loads the CSS part of your webresource.

Hope this helps!

regards,

Hans

This widget could not be displayed.

The log shows " Cannot find web resource module for: com.jira.plugin:myresource ".

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

173 views 2 0
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