Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to incluede Custom JavaScript into Confluence Plugin

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

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
Answer accepted
ConradR
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

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.

0 votes
Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

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;

ConradR
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

try

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

Max Madjarov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 30, 2013

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
TAGS
AUG Leaders

Atlassian Community Events