It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I prevent html macro javascript running when switching into edit mode?

I've written some javascript that does a bunch of asynchronous API calls to display third-party content on the current page.

(I also do this as a way of displaying confluence content instead of using the content macros, because too many content macros on one pages slows the page load enough for users to start complaining; asynchronous loads provide a better user experience.)

This works fine, except that if I click the 'Edit' button, I have to wait while all the javascript re-runs (i.e. creates the view mode again*) before the page even tries to switch to edit mode.

*I presume this always happens when switching any page into edit mode, but we don't normally notice it?

Is there any way to stop the javascript running on this pre-edit page view load? Something wrapped around my code that says "if edit button has been clicked, abort"?

(I don't have access to create plug-ins etc btw - only front-end javascript)

PS - we have collaborative editing enabled

1 answer

1 vote

Looks from there event checker will help

https://developer.atlassian.com/cloud/confluence/jsapi/confluence/

e.g. it helps to me

Thanks for this link (I'm using Confluence server btw).

I wasn't sure how I would have implemented this for my scenario:

I have a page in Confluence containing an HTML macro. In that page I can either write some javascript or link to an javascript file attached to the page. My js is doing ajax calls.

  • When I view the page I see the results of my script.
  • If I click Edit, the script runs again before showing me the edit screen.

Update: as far as I can see this is no longer an issue.

Which might be since the upgrade to Confluence 7.3.1 (or an earlier version and I didn't realise this had resolved itsself as I have added buttons to 'run javascript' to most of my stuff now).

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

7,070 views 6 6
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you