2012-10-02 2 views
2

Atlassian Jira 4.4 플러그인에 웹 리소스를 포함시키는 방법은 무엇입니까?jira 플러그인의 정적 리소스 (예 : JQuery) 사용

골드 피처-의 plugin.xml : 속도 템플릿 리소스를 포함

$("#projects").change(function() { 
$(location).attr('href', "/jira/secure/StatisticsModuleAction!project.jspa?project=" + $(this).find("option:selected").text());}); 

:

<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

$webResourceManager.requireResourcesForContext("com.cs.jira.plugins.statistics-resources") 

전에서 자바 스크립트 함수를 호출하려고 내 statistics.js,이 오류가 발생합니다.

Uncaught TypeError: Property '$' of object [object Window] is not a function

그럼 내가 외부 jQuery 라이브러리를 포함하려고 :

Uncaught TypeError: Object [object Object] has no method 'handleAccessKeys'

이 어떻게 제대로 내 자원을 포함 할 수 있습니다 : 내가 batch.js 다른 오류가 발생했습니다
<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> 

?

+0

플러그인에서 jQuery를 사용해야합니까? 순수한 자바 스크립트를 사용해 볼 수 있습니다. – maxwell

+0

https://developer.atlassian.com/display/AUI/Getting+Started+with+AUI 및 https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module로 시작하겠습니다. – mdoar

답변

0
AJS.toInit(function() { 
// Your code here for .js file 
}); 

문제를 해결하고 항상 Joe Douglas가 대답 한 AJS. $의 $ function을 참조해야합니다.

2

통계 리소스를 올바르게 포함 시켰습니다. 문제는 Jira가 jquery 표준과 다른 참조를 통해 jquery에 대한 액세스를 제공한다는 것입니다. 귀하의 자바 스크립트 코드에서 $AJS.$으로 바꾸면 문제가 해결됩니다.

관련 문제