Hi,
I'm just getting started to create user macros for confluence so I hope this is not a to silly question.
I created an user macro which simply searches for some text on it's confluence page and depending on the search result creates an output.
Simplified it looks like this:
<span id=(resultDate+$content.id)></span>
<script>
$(document).ready(function() {
var dateElement = document.getElementById("(resultDate+" + $content.id+ ")");
var dateResult = "Date result text";
$(dateElement).html(dateResult);
});
</script>
The macro works as expected but when I try to export the page as pdf or word my result is not included in the export.
As far as I searched the forum I guess that exporting is done on the server side and the javascript is done on the client side so that my javascript is not executed when exporting.
How can I achieve that my result is also included in the export-files?
Best regards,
Thorsten
Using javascript in Atlassian applications is always a pain, and generally the second worst way to do anything with them.
User macros are a clumsy way to do javascript too - why not write the macro to do the work properly, as they're designed to do?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the second worst way
Wondering about the first worst way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are correct that the PDF and Word export is server side. You could however, run your user macro and the print to PDF. That happens client side and thus you DOM changes made via JavaScript would be caught.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Up to now the only possible solution apart from using the printing functionality of the browser would be to write a "real" macro and not to use the user macros.
As I'm new to the Atlassian Community: what should I do with my answer? Accept a solution, leave it open?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would accept a solution(s) if the question is answered ... even if it's not the answer you were hoping for. Unfortunately, sometimes the correct answer is "It can't be done the way you want".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
where is the execute method? It makes more sense to pass a json to js from the execute method.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I thought that there is no need for an execute method. The script is automatically executed after the page is loaded
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.