On click of web item call javascript function in jira cloud

Hi Team,

I am creating a Jira plugin for cloud and i want to call a javascript function on click of web item.

How can I do this.

I am new with cloud plugin development.

any Idea on this.

1 Like

Web items are basically hyperlinks, so you can’t directly execute JavaScript when someone clicks on it.

You can however link to another page or use a dialog and execute your JavaScript there (inside an iframe).

Hi @sven.schatter,

How can we add pop up dialog there. any Suggestion.

I am following this document as of now but not sure where i have to add Java script.

https://developer.atlassian.com/cloud/jira/platform/issue-view/

According to the web item documentation you can use the target attribute to open a dialog with it.

If you want to do that you might want to look at the dialog module documentation as well.

Where i can add the below javascript.

AP.require(‘dialog’, function(dialog){
dialog.create({
key: ‘dialog-module-key’
}).on(“close”, callbackFunc);
});

You don’t open the dialog via JS. If you specify a dialog module in the target of the web item the dialog will be opened for you on click.

You just need to implement a dialog module. Your dialog module needs to deliver a HTML document which will be put inside an iframe and from there you can execute JS.

HI @sven.schatter,

Its working thanks but using that javascript I can achieve this view .

Where to addthis script.

Have you looked at the documentation of the Issue Content module linked in your screenshot? According to that you would add that JS inside the document returned by the url specified in the target value of your Issue Content module.

@SarikaDalal, also see the feature request AC-1823. While I wouldn’t really recommend the workaround described there, I do believe it still works.

1 Like

HI,

I have done some work around to call my Javascript after click on web item.

I have added inline dialog with javascript and its working fine for me now.