Binding javascript to dialog created with AJS.FormPopup

Robert Jahrling January 9, 2019

Let's say that I am following https://checkup.atlassian.com/server/jira/platform/tutorial-how-to-create-an-ajax-dialog-4227197/ and I want to add a select list to the dialog that we've created with AJS.FormPopup.

Easy, no problem, modify the .vm file and you're set.

What if you want to bind a function to the select list's change event? 

How do you get this dialog to import JavaScript?

$webResourceManager.requireResource(), which works in other contexts, doesn't work here. CSS and JS files just don't get loaded.

Adding code to the javascript file you create in this tutorial doesn't work either, unless I'm doing something incredibly wrong by adding


$('#selector').change(function() {

  //do stuff

});

 

How can I do this?

2 answers

1 accepted

0 votes
Answer accepted
Robert Jahrling January 10, 2019
<script>

 #include("/js/dialog-js.js")

</script>

 

works, but I kind of feel like there should be a better way.

Robert Jahrling January 10, 2019

(in the velocity template, obviously)

0 votes
Robert Jahrling January 10, 2019

Adding resources to the jira.popup context appears to have no effect.

Creating a custom context appears to have no effect.

Is the only solution to include my javascript in a script tag?

Suggest an answer

Log in or Sign up to answer