Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Inject String into AJS/JQuery in User Macro

Daniel Tam February 23, 2021

Hi,

I'm  trying to figure out how to inject a string into the portion in bold: "jQuery(".label_to_add").click(function(){".  This macro currently work injecting a label to the page by click of a button; however, if more than one page with this macro is included into another, the ".label_to_add" triggers the scripts in multiple pages.  I need to make each of these scripts unique.

Thanks

-------------------------------

## @Param 0:title=Label to add|type=string|desc=Label of interest
## @Param 1:title=Button description|type=string|desc=Text to display on button

<script>
AJS.toInit(function ($) {
jQuery(".label_to_add").click(function(){
jQuery.post(contextPath+"/json/addlabelactivity.action", {"entityIdString": "$content.id", "labelString": jQuery(this).val(), "atl_token": jQuery("#atlassian-token").attr("content") },function(){
window.location.reload();
});
});
});
</script>
<button class="label_to_add" type="submit" color="#0" value=$param0>$param1</button>

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events