Hi,
Currently using Jira 4.4, we have a custom field than is populating 2 other fields using onchange.
We plan to upgrade to Jira 5.1, but the javascript isn't working anymore as Jira5 doc mentions, which is a lillte sad...
Anyway, would anyone be kind enough to help me (and probably many other users) make the following code work in Jira 5.1.
<script type="text/javascript"> function generateURL() { var sel = document.getElementById('customfield_10023'); var selText = sel.options[sel.selectedIndex].text; var Fieldtoreadonly = document.getElementById("customfield_10023"); selText = selText.substr(selText.lastIndexOf('(') + 1); selText = selText.substr(0, selText.indexOf(')')); document.getElementById('customfield_10761').value = 'http://intranet/wiki/index.php/' + selText ; switch (selText) { case '4464': document.getElementById('customfield_10763').value = 'Aviser direction si support pour emballeuse (interface)' ; break; case '4564': document.getElementById('customfield_10763').value = 'Aviser direction si support pour emballeuse (interface)' ; break; case '4470': document.getElementById('customfield_10763').value = 'Aviser direction si support pour emballeuse (interface)' ; break; case '4467': document.getElementById('customfield_10763').value = 'Aviser direction si support pour emballeuse (interface)' ; break; default:document.getElementById('customfield_10763').value = ''; break; } } window.onload = function() { document.getElementById('customfield_10023').onchange = generateURL; } </script>
In advance, thank you!
The Best way to use Javascript in jira is by using webresource, check the following post
https://answers.atlassian.com/questions/47843/strange-javascript-problem-in-create-screen
This is how i did it:
<script type="text/javascript"> (function($) { AJS.toInit(function(){ //function }); JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context) { //function }); })(AJS.$); </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I got it working this way too.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have same issue, want to be able to have javascript fire for creates and edits. But trying to understand this code...would })(AJS.$);
in John's code example be the following to work for Mike's issue?
})
(AJS.$(
'#customfield_10023'
).live(
"change"
,generateURL));
or ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you have to bind your code in NEW_CONTENT_ADDED event
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e,context) { alert("Hello!!!"); });
i have given link in my answer!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thanks for the suggestion, and sorry for the delay, it's vacation season!!
But i'm a little lost, would someone be kind enough to have the code in first post adapted to work with the jquery .live method?
in advance, thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
window.onload = function() { document.getElementById('customfield_10023').onchange = generateURL; }
becomes
window.onload = function(){ AJS.$('#customfield_10023').live("change",generateURL); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Florin, Thanks for the reply,
The code works, but only if I open the form in a new window still, the create/edit popup doesn't call the code, still the same situation...
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use the .live() method from jQuery (AJS).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use the .live() method from jQuery (AJS).
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.
Thanks for the reply,
I tried that but it does not work when creating/updating the issue from the "popup"
If I open the edit window in a new tab, then it works as expected...
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.