How to incluede Custom JavaScript into Confluence Plugin

Hi,

I know this question has been asked several times... but I get nightmares already, i can't get my javascript in my Plugin. Here is resources definition in my atlassian-plugin.xml:

<web-resource key="skilldatenbank.resources" name="Skilldatenbank Plugin Web Resources" >
        <dependency>com.atlassian.auiplugin:ajs</dependency>
        <dependency>confluence.web.resources:ajs</dependency>
        <dependency>confluence.web.resources:jquery</dependency>
        
        <resource type="download" name="confluence-skilldatenbank-plugin.css" location="/css/confluence-skilldatenbank-plugin.css" >
            <property key="content-type" value="text/css" />
        </resource>
        <resource type="download" name="confluence-skilldatenbank-plugin.js" location="/js/confluence-skilldatenbank-plugin.js" >
            <property key="content-type" value="text/javascript"/>
        </resource>
        <resource type="download" name="images/" location="/images"/>

        <context>atl.general</context>
</web-resource>

and so i try to reference this resources in my .vm page.

#requireResource("de.twt.confluence.plugins:skilldatenbank.resources")

but there are neither javacsript nor styles in my page...

what is even more strange, it is not a self-defining <script> rendered in the template...

&lt;head&gt;
        &lt;title&gt;$i18n.getText("catpureskills.page.title")&lt;/title&gt;
        #requireResource("de.twt.confluence.plugins:skilldatenbank.resources")
        &lt;script type="text/javascript"&gt;
            jQuery(document).ready(function()
            {
                alert();
            });

            function fnSendAssessment(arg) {
                alert(arg);
            }
        &lt;/script&gt;

    &lt;/head&gt;

if i start my "plugin" with: atlas-debug it does't work.

Please HELP!!! :-)

2 answers

1 accepted

1 vote
Accepted answer

What is your groupID and your artefactID in your pom.xml and the atlassian-plugin-key in atlassian-plugin.xml?

Maybe "de.twt.confluence.plugins:skilldatenbank.resources" is wrong.

pom.xml

&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
&lt;groupId&gt;de.twt.confluence.plugins&lt;/groupId&gt;
&lt;artifactId&gt;confluence-skilldatenbank-plugin&lt;/artifactId&gt;
&lt;version&gt;1.0&lt;/version&gt;

atlassian-plugin.xml

&lt;atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"&gt;

    &lt;plugin-info&gt;
        &lt;description&gt;${project.description}&lt;/description&gt;
        &lt;version&gt;${project.version}&lt;/version&gt;
        &lt;vendor name="${project.organization.name}" url="${project.organization.url}" /&gt;
        &lt;param name="plugin-icon"&gt;images/pluginIcon.png&lt;/param&gt;
        &lt;param name="plugin-logo"&gt;images/pluginLogo.png&lt;/param&gt;
    &lt;/plugin-info&gt;

try

#requireResource("de.twt.confluence.plugins.confluence-skilldatenbank-plugin:skilldatenbank.resources")

Thanks, I'll try that out. Whether you know why javascript is not displayed on the page... i have included javascript in the VM Page at the header section, but it doesn't work!

&lt;script type="text/javascript"&gt;
            jQuery(document).ready(function()
            {
                alert();
            });

            function fnSendAssessment(arg) {
                alert(arg);
            }
&lt;/script&gt;

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in New to Confluence

How to use Confluence Cloud for stakeholder management

Most of us don’t need much convincing that stakeholder management is important. It just makes sense that keeping everyone in-the-know on projects and assigning clearly defined roles is key to having ...

1,146 views 4 6
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