Hello,
I have created a macro which provides a web form. This is defined in a Velocity template. I have some supporting functions in JavaScript. I have no problems calling the JS if I include it inline with my Velocity template via . The issue is when I segregate it into it’s own file, it appears to not be visible from Velocity.
I’ve followed the instructions per the development docs Including Javascript and CSS resources
yet I haven’t had any success getting this to work. I’ll also need to do the same with a CSS file shortly.
Here are some snippets
atlassian-plugin.xml
<web-resource key="createinitiative-web-resources" name="createInitiative Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<dependency>com.atlassian.auiplugin:aui-flag</dependency>
<resource type="download" name="createInitiative.css" location="/css/createInitiative.css"/>
<resource type="download" name="createInitiative.js" location="/js/createInitiative.js"/>
<resource type="download" name="images/" location="/images"/>
<resource type="velocity" name="template" location="/templates/createInitiative.vm"/>
<context>createInitiative</context>
</web-resource>
webForm.vm
#requireResource("com.trustvesta.plugins:createinitiative-web-resources")
#requireResource("confluence.web.resources:ajs")
#set($pagePropertiesHtml = $webFormMacroObject.getProperties())
<input id="createinitiative" class="aui" type="button" value="Create Initiative" onclick="createInitiative()" >
Created Date
<input class="aui-date-picker" id="submitdate-picker" type="date" max="2020-01-01" min="2017-01-01" />
createInitiative.js
AJS.toInit(function () {
AJS.log("Hello World");
});
function successResponse(response, textStatus) {
AJS.log("Success: " + response);
}
function errorResponse(xhr, textStatus, errorThrown) {
AJS.log("Error: " + xhr + textStatus + errorThrown);
}
function createInitiative() {
jQuery.ajax({
type: "POST",
contentType: "application/json",
url: AJS.contextPath() + "/rest/jirarequest/1.0/createissue",
data: '${pagePropertiesHtml}',
dataType: "text",
success: successResponse,
error: errorResponse
});
}
At the very least, I’d like to get to the point where the “Hello World” shows in the browser console as the DOM loads. Can anyone suggest what I missed?
Thanks
Michael