How to retrieve macro parameters of Confluence? Edited

I've created a user macro for Confluence and I was trying to retrieve macro parameters by using attribution "data-macro-parameters" to re-edit this macro and update parameters of this macro.  

Now I can retrieved correct parameters when there is only one macro on the Confluence page, BUT if added multiple same ,macros on the same page, then re-edit any of macro except the first one, I always get the first's parameters, that because these macro all has attribution "data-macro-parameters".   How could identify which macro user wants to edit?

Any help could greatly appreciated.

These macros have similar html code:

<img class="editor-inline-macro" src="/confluence/plugins/servlet/confluence/placeholder/macro?definition=e3Jtc3ZpZXdlci1tYWNybzpQYXJhbWV0ZXJzPXsicHJvamVjdCI6WyJXSElURSJdLCJ0YWciOlsiV0hJVEUxMjggcHVibGljIl0sImZpZWxkcyI6WyJpZCIsIkNhdGVnb3J5IiwiRGVzY3JpcHRpb24iLCJNaW4iLCJUeXAiLCJNYXgiLCJVbml0Il0sIm5vbnBhcmFtZmllbGRzIjpbImlkIiwiQ2F0ZWdvcnkiLCJUeXBlIiwiRGVzY3JpcHRpb24iXX19&amp;locale=en_GB&amp;version=2" data-macro-name="my-macro" data-macro-parameters="Parameters={&quot;project&quot;:[&quot;Woods&quot;],&quot;tag&quot;:[&quot;WHITE128 public&quot;],&quot;fields&quot;:[&quot;id&quot;,&quot;Category&quot;,&quot;Description&quot;,&quot;Min&quot;,&quot;Typ&quot;,&quot;Max&quot;,&quot;Unit&quot;],&quot;nonparamfields&quot;:[&quot;id&quot;,&quot;Category&quot;,&quot;Type&quot;,&quot;Description&quot;]}" data-macro-schema-version="1">


2 answers

0 votes
Ann Worley Atlassian Team Nov 21, 2017

Hi! May I know what tool you are using to retrieve the macro parameters? 

Im using Tinymce as editor. And using JavaScript to getting parameters.

Hi AustinS,

Confluence has jQuery built in, so you can iterate over the html elements you want with something like

AJS.$('img.editor-inline-macro').each(function(index) { console.log( index + ": " + $( this ).text() ); });

You can see more about the each() function in the jquery docs here

You may find if you enter that JavaScript into tinymce then it will strip out the code, so better to put it into a HTML macro block.



Thanks James, but what I need is when user randomly click to edit the one macro of this page, can retrieve the parameters of this one, not the first one's. 

We do not need to iterate to get each of them, just want to identify which macro is user 'click to edit'.  Because for each <img>, there is no 'id' attribution to identify them. Any idea ?

Thanks again.


Ah, so you mean when the editor is being used you want to get the one that is selected?

Hmmm, that's pretty tricky because you need to insert a click listened in to the DOM and wait for events.

Something like this would do the trick

AJS.$('img.editor-inline-macro').on('click', function() { alert('yes!'); });


But it doesn't look like the AJS object is defined when using the editor for the editor items.

I'd suggest asking over in the developer community at



Thanks for your replies, James.

Will do that.

Happy Thanksgiving!


Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

1,021 views 51 8
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you