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

What the best way to access the spaceKey with JavaScript in Confluence?

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 4, 2011

I see that the spaceKey is stored here:

<meta id="confluence-space-key" name="confluence-space-key" content="GHDEV"> 

...but is that the best source?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

7 votes
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 4, 2011

A-ha! AJS.params.spaceKey is probably best.

In fact, there's all manner of handy stuff in the AJS.params JavaScript object on both Confluence and JIRA.


And if you place your own i18n in a hidden fieldset, AJS.params will be populated with your own stuff

e.g. if your plugin has an i18n value...

hello.david=Hello David!

Add the fieldset to the page:

<fieldset class="hidden parameters">
<input type="hidden" id="helloDavid" value="$action.getText('hello.david')">
</fieldset>

...then call AJS.params.helloDavid, you'll get Hello David!

See Confluence UI Guidelines for more info.

Thomas Wendel
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 3, 2011

The page Atlassian User Interface (AUI) Developer Documentation is also a good source of information for AJS functions.

TAGS
AUG Leaders

Atlassian Community Events