I added a button(web item) to the search question page, but I couldn't do it by injecting JS binding buttons
This is a screenshot of the item I added
this is my js script
$("key1").on("click",function(){
alert('call me');
});
When I click that button, it just refreshes the page. Can anyone help me, thank you
Try putting this in your javascript instead:
AJS.$(document).ready(function () {
AJS.$("#key1").on("click",function(e){
e.preventDefault();
alert('call me');
});
});
A few things going on,
1) makes sure to bing the event only after the page is done loading (to be sure the web item is available
2) In jira, the Jquery is called with AJS.$
3) To get the item you created with key=key1, you need an "id" selector, so start it with #
4) User preventDefault() to stop the default action on the <a> tag that you are clicking
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, where do you put the javascript? Is that stored in a scriptrunner web resource?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.