Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to reload the web panel content after a click on a button on the jira issue view details page

Bechir CHARFI August 1, 2019

I have a web panel displayed on jira issue details view page.
The content of this web panel should be refreshed after a click on a submit button (that also exist on same webpanel section).
The content is generated using a velocity template that get data from a ContextMap provider.
Currently, I use a location.load() after a click on submit button, but we need only refresh the webpanel component not reload the issue view page to get the new data.

web panel declaration:

	<!-- Panel to display data from external app -->
	<web-panel name="Test"
		i18n-name-key="data-panel.name" key="data-panel"
		location="atl.jira.view.issue.left.context" weight="200">
		<description key="data-panel.description">The Issue View Data Panel</description>
		<context-provider class="com.plugin.provider.ContextProvider"/>
		<resource name="view" type="velocity"
			location="/templates/webpanel-module/data-panel.vm" />
		<supports-ajax-load>true</supports-ajax-load>
	</web-panel>

data-panel.vm file:

<div id="content-attach"  style="display:none;">
    <form class="aui" action="">
        <div class="input-group">
            <input type="text"
                    class="controls-input" id="inputUrl"/>
            <input class="aui-button aui-button-primary attach-button" id="submit-form" type="submit" value="Attach Data"/>
        </div>
    </form>
 
</div>

<div id="content-results">
....
</div>

issue-view-controller.js :

AJS.$(function(){
   
   AJS.$("#submit-form").click(function(e){
       e.preventDefault();
       ...
       AJS.$.ajax({ 
   				url: AJS.params.baseURL+'/rest/testforjira/1.0/config/object/issue/link',
   				type: 'PUT',
   				contentType: 'application/json',
   				data: JSON.stringify(dataInput),
   				processData: false,
   				success: function() {
                       AJS.$("#content-attach").hide();
                       // refresh web-panel data
   		location.reload();
                       AJS.$("#content-results").show();
                       showSuccessFlag('Object is linked to Jira issue.');
   				},
   				error: function() {
   					AJS.$("#content-attach").show();
                       AJS.$("#content-results").hide();
                       showErrorFlag('Failed to link Object to jira issue.');
   				}
       });   
   });
 });

1 answer

1 vote
Nhac Tat Nguyen
Contributor
October 27, 2020 edited

I know this is an old question, but in case someone needs it.

You can replace location.reload() by:

JIRA.trigger(JIRA.Events.REFRESH_ISSUE_PAGE, [JIRA.Issue.getIssueId()]);

 

ak5123
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 26, 2021

@Nhac Tat Nguyen Can you help me with finding docs for various JIRA methods available?

Nhac Tat Nguyen
Contributor
August 26, 2021

@ak5123 As far as I know, there are no documents about those methods, but you can use the browser dev tool to inspect the available methods and try them.

Just print the JIRA or JIRA.Events 
Screenshot 2021-08-26 195440.png Screenshot 2021-08-26 195530.png

Like 2 people like this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events