Issues facing on controls added through custom field description (javascript)

白昼怎懂夜的黑 提交于 2019-12-11 19:21:26

问题


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.

  1. 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)

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!