Hi!
Jira 8.5.2
I am writing a Jira Plugin which creates a Panel based on a .vm file.
I realized, that when the the JIRA.CONTENT_ADDED_REASON.panelRefreshed handler for my panel is called, the Html Code is not present in the DOM and therefore my event handlers dont work.
This just happens in the Issue List View, not in the Detail View.
Any idea why this happening ?
Regards,
Hans
tjoy
June 10, 2021, 4:30pm
2
Could you elaborate how this panel is rendered, is it a <web-panel>
? How is the JavaScript listening to this event loaded?
Best regards,
TJ
Hi!
Yes I am using a “web-panel” with a .vm file.
Within the .vm file, I have
<a id="my-id" href="#">My text</a>
The JS gets loaded via a web-resource, within the .js file I have
AJS.toInit(function() {
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
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
if(module === 'my-panel') {
$context.find('#my-id').each(function() {
$('my-id').click(function(e) {
});
}
});
}
break;
});
});
Interestingly ‘#my-id ’ is NOT found when “module === ‘my-panel’”
When I remove the
if(module === 'my-panel')
‘#my-id ’ is found
because after my panel, panelRefreshed is called with
module === ‘’
So the DOM Elements of my panel are NOT available when panelRefreshed is called for my panel, instead for the panel with an empty module.
It took Me quite a while to check this out, is this desired behaviour ?
Regards,
Hans