I want to upgrade a plugin, but the Javascript in the plugin is not work. The javascript controls the "change" event of a "Select".
I have seen this:https://developer.atlassian.com/display/JIRADEV/Custom+Fields+that+use+CSS+or+JavaScript+Web+Resources+in+JIRA+5.0
The way to use JS has been changed since JIRA 5.0+, would someone give me some ideas.
Its source code is like this:
original JS:
AJS.toInit(function() {
(function($) {
$('#select-issue-type').change(function() {
$('.cpji-loading').show();
$('#fields').empty();
var projectKey = $('#project-key').val();
var issueType = $('#select-issue-type :selected').val();
$.get('../GetFieldsHtmlAction.jspa?projectKey=' + projectKey + '&selectedIssueTypeId=' + issueType, function(data) {
$('#fields').append($(data));
$('.cpji-loading').hide();
});
});
$('#select-issue-type').trigger('change');
})(AJS.$);
});
Original .vm:
<div id="fields"> </div>
Original atlassian.xml:
<web-resource key="cpjiadminrs">
<context>atl.general</context>
<resource type="download" name="cpjiadmin.js" location="js/cpjiadmin.js"/>
<resource type="download" name="cpjiadmin.css" location="css/cpjiadmin.css"/>
</web-resource>
No need to edit the java script.
make sure your additing this entry in the atlassian-plugin.xml file.
<web-resource key="scriptaculous" name="scriptaculous" >
<resource type="download" name="yourfile.js" location="temp/res/yourfile.js" />
</web-resource>
and then go to your velocity file and edit it to the .
#requireResource("your plugin key+ :cpjiadminrs")
make sure and check the syntax for the #requireResource on atlassian it will be help ful for you
if still not working then i cannot help you then you can really cry.
Have you tried setting the context to atl.general?
<web-resource name="AAC Connector Resources" i18n-name-key="aac-connector-resources.name" key="aac-connector-resources"> <context>atl.general</context> <description key="aac-connector-resources.description">The AAC Connector Resources Plugin</description> <dependency>com.atlassian.jira.plugins.support-resources:bindToEdit</dependency> <resource name="aac-connector.css" type="download" location="assets/css/aac-connector.css"/> <resource name="aac-connector.js" type="download" location="assets/js/aac-connector.js"/> <resource type="download" name="assets/" location="assets/"/></web-resource> |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
please try.
#requireResource("your plugin key+ :cpjiadminrs")
in your velocity template it should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yes, there is <context>atl.general</context> in the <web-source>
and at the head of the related vm file has the following:
<html> <head> <meta name='decorator' content='atl.general'>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your kindly answer, but it still not work. 555... I want to cry.
The css in the web-source can be added correctly, but the javascript could not be executed.
Does it need to modify the javascript file?
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.