1. Copy your test.js script to the following folder: /opt/apps/jira/apache-tomcat/atlassian-jira/includes/js,
2. Use jQuery.getScript in the given field description in the project's Field Configuration.
<script type="text/javascript">
if (jQuery.browser.mozilla){
jQuery.getScript("../includes/js/test.js")
.done(function(script, textStatus) {
console.log( "Loading javascript '../includes/js/test.js': " + textStatus );
})
.fail(function(jqxhr, settings, exception) {
console.log("Loading javascript '../includes/js/test.js': " + exception);
})
}
else if (jQuery.browser.msie || jQuery.browser.safari){
jQuery.getScript("../includes/js/test_IE.js")
.done(function(script, textStatus) {
console.log( "Loading javascript '../includes/js/test_IE.js': " + textStatus );
})
.fail(function(jqxhr, settings, exception) {
console.log("Loading javascript '../includes/js/test_IE.js': " + exception);
})
}
</script>
You could see in the browser's console that
"Loading javascript '../includes/js/test.js': success " in Firefox,
"Loading javascript '../includes/js/test_IE.js': success " in Chrome and IE.
Later in IE you got
"Loading javascript '../includes/js/test_IE.js': Not Found "
error but ONLY in IE. It worked well in Chrome.
It is a known issue, you can read more details here (in IE8 and IE9 the URL
rewriting is not supported - in IE11 the javascript
is loaded successfully).
Working well in ALL browsers changing the filepath of the javascript.
Instead of using
jQuery.getScript("../includes/js/test.js")
you have to use
jQuery.getScript("/jira/includes/js/test.js").
Easy :-)
Nincsenek megjegyzések:
Megjegyzés küldése