Jira Plugin Webpanel loaded multiple times in List View

Hi!

Jira 8.5.2, ATLAS Version 8.0.16

I am writing a Jira Server Plugin which incorporates a Webpanel which uses a velocity file.

When I open an Issue in the Detail View, everything works fine:

AJS.toInit(function() {
    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
         var $context = $(context);
         switch(reason) {
             case JIRA.CONTENT_ADDED_REASON.panelRefreshed:
                $context.find(element_in_velocity).each(function() {
                   doSomething();
                });
               break;
    });
}

At the end of my velocity file I am using


<script>
    console.log('I am here !!!');
</script>


In the console I see, that ‘I am here !!!’ appears only once.

When I view Issues in the ListView, things get complicated…

Because

 

    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) 

doesnt work, when opening Issues in the List View, I am using


            JIRA.bind(JIRA.Events.ISSUE_REFRESHED, function(e, context, reason) {
              doSomething();
            });

Unfortunately, ‘I am here !!!’ sometimes appears 3 times and overwrites data that I had already changed during the loading.

I dont now how to handle this and why this happens.

Any hints on how to solve this would be greatly appreciated!

Thanx in advance!’
Hans

Hi,

I am also facing the same issue. have you found any solution?

Thanks

Hi!

I am using something like this:

    JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
         // context
         var $context = ((typeof context !== 'undefined') ? $(context) : $(''));
         var module = ((typeof context !== 'undefined' && typeof context[0] !== 'undefined') ? context[0].id : '');
  	 
         switch(reason) {
             case JIRA.CONTENT_ADDED_REASON.panelRefreshed:
                 // our div found ?
                 $context.find('mypanel').each(function() {
                    // check for css class
                    if(!$(this).hasClass('myclass')) {
                        $(this).addClass('myclass');
                    } else {
                        // load stuff
                        setTimeout(function() {  showData(); }, 1000);
                    }
                 });
                 break;
             case JIRA.CONTENT_ADDED_REASON.pageLoad:
                break;
         }
    });

Regards, Hans

See this thread also

Same AUI.dialog2 appears 2 times in Page Source