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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Inject String into AJS/JQuery in User Macro

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
Community showcase
Published in Confluence

Confluence Mythbusters: Does Atlassian even use Confluence?

Hi, Confluence collaborators! As part of #Confluence-Collaboratory month, we’ve created a very special Mythsbusters segment, where we're dive into an interesting myth and uncover the truth behind i...

1,683 views 7 31
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you