I am new to the macro development and I have the following issue with my macro plugin.
I am creating a template in a .vm file which I am populating from a RestService, but when there are multiple instances of the macro on a page I cannot address each of the elements in the javascript which leads to failing behaviour of the macro as there now multitudes of each component to which I want to bind ajax calls.
So what should I do to namespace my components properly?
I guess I could use the macro id and add it to each button in the .vm but how can I pass the id to the js context to address it in a velocity like way?
I hope I made my issue clear, communicating a problem is hard…
Thanks in advance.
It depends on what you’re doing etc. What we do for Build Status for Confluence is to generate our id based on the configuration parameters. That way if 2 macros share the same configuration, there is only one rest call issued to the backend…
when ýou are already developing a macro plugin, then you could do the REST stuff in a Java class. Maybe you won’t even need REST for that at all. If it is in the same Confluence instance, just call the classes you need. Maybe some example code would clarify the problem.
*You could also add a data-your-macro-id or similar to each of your root macro element so that you can reference it by some distinct hook later if needed.