问题
Below is the stuff which is included in field descirption so, i could have summary row appear.
<script type="text/javascript">
var table = AJS.$('<table style="margin-left: 130px;">').append(
AJS.$('<tr>').append(
"<td style='border: 0px; width: 90px; margin-left: 1px; font-weight: bold; background-color: rgb(204, 255, 255);'><div id='customfield_summary_2:input1'>0</div></td>"
).append(
"<td style='border: 0px; width: 90px; margin-left: 1px; font-weight: bold; background-color: rgb(204, 255, 255);'><div id='customfield_summary_2:input2'>0</div></td>"
)
);
if(AJS.$("#edit-issue-dialog").length)
{
AJS.$("#customfield_11278\\:input1").parent().parent().parent().parent().parent().before(table);
}
else
{
AJS.$("#customfield_11278\\:input1").parent().parent().parent().parent().before(table);
}
</script>
<script type="text/javascript">
AJS.$("#customfield_summary_2\\:input1").text(
"$" + (
parseInt(AJS.$
("#customfield_11278\\:input1").val()
) +
parseInt(AJS.$
("#customfield_11279\\:input1").val()
) +
parseInt(AJS.$
("#customfield_11280\\:input1").val()
)+
parseInt(AJS.$
("#customfield_11281\\:input1").val()
)+
parseInt(AJS.$
("#customfield_11282\\:input1").val()
)+
parseInt(AJS.$
("#customfield_11283\\:input1").val()
)+
parseInt(AJS.$
("#customfield_11284\\:input1").val()
)+
parseInt(AJS.$
("#customfield_11285\\:input1").val()
)
).toString()
);
</script>
couple of issues: 1. get duplicate summary row (field that added through jquery) when close the edit screen. How it should be resolve. 2. This summary custom field which appears on view screen and edit screen. Now, In View screen, when i do inline edit for other field and save then this summary custom field (appear through client side javascript) gets disappear and need to refresh screen then after it gets appear and value gets updated.
please let me know on above queries. Thank You
回答1:
Found solution as follow @Kuf in comment How to develop custom field (plugin) having multiple input fields.
remove duplicated - have every time - remove table before appending and kept all in setInterval which resolve the issue.
setInterval(function()
if(AJS.$("#edit-issue-dialog").length) {
AJS.$("#customfield_11278\:input1").parent().parent().parent().parent().parent().before(table); } else { AJS.$("#customfield_11278\:input1").parent().parent().parent().parent().before(table); },2000)refresh inline editing: ave used setInterval as below:
setInterval(function() {
AJS.$("#customfield_summary_2\:input1").text( "$" + ( parseInt(AJS.$ ("#customfield_11278\:input1").val() ) + parseInt(AJS.$ ("#customfield_11279\:input1").val() ) + parseInt(AJS.$ ("#customfield_11280\:input1").val() )+ parseInt(AJS.$ ("#customfield_11281\:input1").val() )+ parseInt(AJS.$ ("#customfield_11282\:input1").val() )+ parseInt(AJS.$ ("#customfield_11283\:input1").val() )+ parseInt(AJS.$ ("#customfield_11284\:input1").val() )+ parseInt(AJS.$ ("#customfield_11285\:input1").val() ) ).toString() );, 2000);
Thanks
来源:https://stackoverflow.com/questions/17297025/issues-facing-on-controls-added-through-custom-field-description-javascript