I am reading this resource http://confluence.atlassian.com/display/CONFDEV/Including+Javascript+and+CSS+resources. But I suppose some other info is also required to include a javascript file.
I had updated my atlassian-plugin.xml file with the following code
<web-resource key="my.js.resources">
<resource type="download" name="menu.js"
location="javascript/menu.js"/>
<context>page</context>
<dependency>confluence.web.resources:ajs</dependency>
</web-resource>
But it is not including my js code. "menu.js" contains the following code:
<script>
alert("Hello World");
</script>
I had tried putting alert() inside AJS.toInit(function(){ }) as well. That too did not work. What am I missing?
Community moderators have prevented the ability to post new answers.
Your example looks reasonable. give it a name though...
<web-resource name="My JavaScript Web Resource" key="my.js.resources">
<resource type="download" name="menu.js" location="javascript/menu.js"/>
<context>page</context>
<dependency>confluence.web.resources:ajs</dependency>
</web-resource>
Also, menu.js should be in a folder called javascript in the same folder as atlassian-plugin.xml. It should not include the script tags. This will break the javascript. To test the inclusion of the JavaScript, View Source in a browser & search for menu.js
David,
I have put the script in javascript directory and do not have script tags in it, just plan alert();
Andres,
I am not creating a seperate gadget. I want to execute my javascript (menu.js) in Page context.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<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>
test.js is just includes alert("haha"); and , #requireResource("com.jira.plugin:myresource") #includeResources()
is also added in my jira gadget. But it still doesnot work . does any body help me ? Thanks .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
David,
My fault. I had script tag in the menu.js. Removed that and it solved the problem.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
are you includding that resource on your gadget spec?
#requireResource("yourResource")
#includeResources()
something like that i guess...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.