如何在Atlassian Jira 4.4插件中包含Web資源?在jira插件中使用靜態資源(如JQuery)
Atlassian的-plugin.xml中:
<web-resource key="statistics-resources" name="statistics">
<resource type="download" name="statistics.js" location="js/statistics/statistics.js"/>
<dependency>jira.webresources:jira-global</dependency>
<context>com.cs.jira.plugins.statistics-resources</context>
</web-resource>
statistics.js:
$("#projects").change(function() {
$(location).attr('href', "/jira/secure/StatisticsModuleAction!project.jspa?project=" + $(this).find("option:selected").text());});
包括Velocity模板資源:
$webResourceManager.requireResourcesForContext("com.cs.jira.plugins.statistics-resources")
當我嘗試從調用javascript函數我statistics.js,我得到這個錯誤:
Uncaught TypeError: Property '$' of object [object Window] is not a function
然後我試圖包括外部jQuery庫:
<web-resource key="statistics-resources" name="statistics">
<resource type="download" name="jquery-1.8.2.js" location="js/lib/jquery-1.8.2.js"/>
<resource type="download" name="statistics.js" location="js/statistics/statistics.js"/>
<dependency>jira.webresources:jira-global</dependency>
<context>com.cs.jira.plugins.statistics-resources</context>
</web-resource>
我得到了batch.js另一個錯誤:
Uncaught TypeError: Object [object Object] has no method 'handleAccessKeys'
我怎麼能包括我的資源是否正確?
是否有必要在您的插件中使用jQuery? 你可以嘗試純JavaScript。 – maxwell
我會從https://developer.atlassian.com/display/AUI/Getting+Started+with+AUI和https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module – mdoar