In issue edit screen, unable to get updated value of customfield using javascript.


I have added below javascript on textbox custom field's description.

setInterval(function(){console.log('value is:'+AJS.$("#customfield_11426\\:input1").val());  //unable to get updated value on each interval tick, it just prints initial value which is found while loading edit issue screen.

It executes on 2 sec but it just print same value of input1 textbox instead of updated values.

(just take the value which is found while loading issue edit screen but unable to get updated textbox values).

i need these updated value for further calculation.

Can you tell me what can be the cause and how to resolve .

Thank You

3 answers

This widget could not be displayed.
try with 		
$('#customfield_11426').change(function() {  
  var val = $('#customfield_11426').val();



This widget could not be displayed.

your code will execute on page load, to get latest value of the field you have to place your code inside some event

something like follows

$('#customfield_11426').bind('keypress', function (e) {
  //add your code here      

I have replaced and how it works -

when update the textbox valut to '157' then console.log prints '15' for AJS.$(this).val() and not 7. when give value - 1578 then shows 157. so, last char not cosndering and also, when do backspace to remove char then also it does not update value. any other event have to cosnider..?

also, when i show in "firebug" then it inspect the value as same value which is on loading the screen and no updated value.

This widget could not be displayed.

Hi @dhaval soni ,

Change event will work correctly, where keypress, keydown,keyup are all keyboard events which will have some syncing issues, whatever you have discussed earlier is an keyboard value syncing issue,blur can also be used but when the field loses it's focus only - blur event will be called, Change is the correct event, whenever a value changes, this event will be called.So, Change event will work correctly for you.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Thursday in United States

Local Atlassian Research Workshop opportunity on Sep. 28th

We're looking for participants for another workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sh...

36 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you