Get MacroBrowser confluence-content input

Hi everybody,
I am writing a Confluence Macro and I would like to get the User Input of the input field “Page”, type “confluence-content”.

My xhtml-macro definition is:
<xhtml-macro name=“select-child-page”
title=“Link child page”
class=“com.alma.confluence.plugin.macro.ChildPageLink”

             key="select-child-page">
    <category name="development"/>
    <parameters>
    	<parameter name="Page" type="confluence-content" required="true">
    	    <option key="showNameInPlaceholder" value="false"/>
            <option key="showValueInPlaceholder" value="true"/>
        </parameter>
        <parameter name="ChildPage" type="enum" required="false">
            <option key="showNameInPlaceholder" value="false"/>
            <option key="showValueInPlaceholder" value="true"/>
        </parameter>
 </parameters>

</xhtml-macro> 

And the javascript:
ChildPageLink.prototype.fields = {
“confluence-content”: {
“Page”: function (param, options) {
console.log(“Page”);
}
},
“enum”: {
“ChildPage”: function (param, options) {
console.log(“Child Page”);

			$('#macro-param-Page').change(function () {
				var page = AJS.$('input#macro-param-Page');
				console.log(page);			

            });
}

}
}

Could you help me in this topic? How can I read out the user input of the field “Page” (confluence-content)?
Thank you in advance,
Eva

Hi,

I don’t know exactly how you use the ChildPageLink.prototype.fields in JS (I would like to see the surrounding code) and I don’t know if you want to have the input when saving the Macrobrowser dialog or just when selecting a page in the autocomplete, so here you have some code for both. Normally, we (in our dev team) override the Macrobrowser functions beforeParamsSet (which gets triggered when the dialog opens) and beforeParamsRetrieved (which gets triggered when the dialog is closed/saved) with AJS.MacroBrowser.setMacroJsOverride:

	AJS.toInit(function () {
		AJS.MacroBrowser.setMacroJsOverride("select-child-page", (function () {

			/**
			 * MacroBrowser start
			 */
			function beforeParamsSet (paramMap) {
				// Event listener for the autocomplete with a second parameter that contains the selected content
				$("#macro-param-Page").on("selected.autocomplete-content", function (event, selectedContent) {
					console.log("SELECTED CONTENT", selectedContent);
				});
				return paramMap;
			}

			/**
			 * MacroBrowser save/preview
			 */
			function beforeParamsRetrieved (paramMap) {
				console.log("beforeParamsRetrieved", paramMap);
				return paramMap;
			}

			return {
				beforeParamsSet: beforeParamsSet,
				beforeParamsRetrieved: beforeParamsRetrieved
			};
		}()));
	});

The event selected.autocomplete-content is pointed out by Atlassian in their documentation: JavaScript Components