Render page resources (image,js,css,cdn) in Confluence HTML Macro but with limited scope

Stefan Mueller
Contributor
March 16, 2019

Hallo,
I use the HTML Macro to add some decent visualized object and JavaScript.
As I added Bootstrap script files

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>

what makes the standard Confluence buttons not usable.
Any chance to limit the scope of the above-mentioned scripts to render only a dedicated section of my HTML?

I found Limiting scope of JavaScript source, could that be a solution?
I haven’t got it to work yet :( .

1 answer

0 votes
Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 18, 2019

Hello there! That is an interesting question, Stefan.

I went ahead and tested this on a local instance running Confluence 6.14.2. Initially, adding only the script lines Confluence does indeed show problems.

The page tree does not work and there are no Space Tools for example.

However, when I add the following after both scrip lines there are no more problems:

<script> altjquery = $.noConflict(true); </script>

So, in the end you did find the correct solution for this! The HTML Macro content looks like this on my side:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script> altjquery = $.noConflict(true); </script>

Looking forward to your reply Stefan!  Let us know your findings.

Stefan Müller March 18, 2019

hey thx for your answer, will test that :).
I had the same discussion in a German forum and will add their code here but it isn't 100% clear for me yet but with your input, I'm optimistic to get all clarified and get it running!

stefan

Diego
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 19, 2019

Thanks for getting back Stefan!

Let us know if this works for you just like it worked for us. If you still have questions, come ask us!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events