I have an Atlassian SDK webwork1 module with its view:
<webwork1 key="ai-config" name="AI Config" i18n-name-key="ai-config.name">
<description key="ai-config.description">The AI Config Plugin</description>
<actions>
<action name="com.softgile.jira.webwork.AIConfigAction" alias="AIConfigAction">
<view name="success">/templates/ai-config/success.vm</view>
</action>
</actions>
</webwork1>
In the view I have several forms:
<form class="aui" id="configForm" method="post" action="AIConfigAction!saveIp.jspa">
...
</form>
<form class="aui" id="serviceName" method="post" action="AIConfigAction!saveService.jspa">
...
</form>
Also I have a button there, which is controlled with JS:
<div class="field-group">
<label for="authenticate">
<span class="aui-icon aui-icon-large aui-iconfont-app-access">Insert meaningful text here for accessibility</span>
</label>
<div class="buttons">
<button class="aui-button aui-button-primary" id="authenticate">Authenticate</button>
</div>
</div>
In JS file I have something like this:
AJS.toInit(function(){
AJS.$(document).on('click', '#authenticate', function(e) {
e.preventDefault();
alert("authenticate");
});
});
Both forms work okay, and JS works when I click the button. But JS stops working when I submit one of the forms, it works only before submitting forms. I see that URL is changing from AIConfigAction.jspa
to AIConfigAction.saveService.jspa
and in that case JS not working. How can I make JS work?
I have found the solution myself. So, the problem in my case was that I was including web-resources inside doExecute() method of the Webwork. That is why after calling other methods like doSave() web-resources stopped working.
Solution - move web-resources inclusion to Webwork constructor:
@Inject
public AIConfigAction(WebResourceManager webResourceManager) {
webResourceManager.requireResourcesForContext("myPlugin");
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.