Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Pre Save Hook

frenchy198588
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 24, 2019

Is there any way I can create a modal popup when a user clicks the save or update buttons on a page so that I can ask them to add a piece of required supporting information for the page?

My use case is that every page is required to have a banner detailing if it is commercially sensitive or one of another few caveats. I don't want to rely on people adding labels etc after the page was saved, I'd rather make it a required field somehow. 

I've seen a confluence instance with a pop up that appears on clicking the save button which opens a dialog / modal area, asks you to fill in a form then saves the page with that extra info. I've no idea how they've done it though.

The closest I've gotten is a on page save event on the server side, but can't figure out how to do this client side.

Any ideas? 

1 answer

0 votes
Sven Schatter _Lively Apps_
Atlassian Partner
November 24, 2019

As far as I'm aware there is no real API for this in the frontend. You'll have to come up with your own solution. A possible hack could be to kidnap the original save button and replace it with your own, like this:

AJS.toInit(function() {
var $original = $('#rte-button-publish');
var $clone = $original.clone();

$original.hide().attr('id', '#rte-button-publish-original');
$clone.insertAfter($original);

$clone.on('click', function(e) {
e.preventDefault();
// replace with your own dialog/logic.
var shouldSave = confirm('bla bla bla');
if (shouldSave) $original.click();
});
});

This should be fine if you only use this internally, but please don't put something like this into a Marketplace app! ;)

Cheers,
Sven

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events