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

How to render Confluence macro inside Inline Dialog (AUI) ?

Miikka Miikka October 27, 2011

I am trying to render a Confluence macro inside an Inline Dialog (AUI).

I finally got this working in Safari but not in Firefox (something to do with "alert" function i guess?). Is there a simpler or any other way to do this or how to get this workin also in Firefox ? The code below is pasted from my theme plugins "main.vmd" where i m trying to get this inline dialog working.

<!--hidden div element contains rendered macro -->
<div id="favhidden" style="display:none!important;">
    $helper.renderConfluenceMacro("{favpages:maxResults=$maxFavouritePages}"))
</div>
<!-- link that opens up the inline dialog -->
<li><a id="hoverLink-10" href="#">Suosikkisivuni</a></li>

<script type="text/javascript">
// first remove all line breaks from rendered macro
    var nrivistr = favhidden.innerHTML;
    var uusistr = nrivistr.replace(
    new RegExp( "\\n", "g" ),""
    );

window.onload = function() {
    AJS.InlineDialog(AJS.$("#hoverLink-10"), 10,
    function(contents, trigger, showPopup){

	contents.html('<div id="favresults" style="padding: 15px 10px;">' + uusistr + '</div>');
 	showPopup();
},{onHover:false, hideDelay:500, isRelativeToMouse:true, useLiveEvents:true}).bind('beforeShow', function() { alert( uusistr) } );
}

</script>

-- Thanks

2 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Vikash Kumar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2013
0 votes
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 20, 2012

I'm doing the same thing at the moment with the following strategy:

- using Velocity, render the content of the Inline Dialog somewhere on the page in a container with "display: none"

- onload, assign the Inline Dialog and append a clone of the container with JavaScript

Look at the following code:

(function($) {

AJS.toInit(function() {
   var generateDialog = function($contentDiv, trigger, doShowPopup) {
	 var $contents = $('#my-dialog-container').clone(); // where the stuff is you want to show in the dialog
	 $contents.show();
	 $contentDiv.empty();
	 $contentDiv.append($contents);
	 doShowPopup();
  },

  dialog = AJS.InlineDialog(
     $('#my-dialog-trigger-link'),
    'my-dialog-id',
    generateDialog,
    { /* options, if you need */ });
});

}(jQuery));

However, if you need fresh content for the dialog, you must do some Ajax and return the rendered Velocity template from the server. Isn't very difficult either.

Hope that helps!

TAGS
AUG Leaders

Atlassian Community Events