What is the exact event that gets thrown when this button in confluence is clicked and we land in the editor?

java
confluence-server

#1

I am basically looking to capture the Java event, when the user is trying to create a page out of a user template and clicks this create button as shown below, please let me know :


#2

There isn’t an event on the server side that maps 1:1 to client side events. That said - there is a page created event: https://docs.atlassian.com/atlassian-confluence/6.5.2/com/atlassian/confluence/event/events/content/page/PageCreateEvent.html which should be getting triggered whenever a new page is created.


#3

Please note, that the “PageCreateEvent” is not thrown, when the “Create” button in the screenshot is clicked, but when the “publish” button is pressed.


#4

As @danielwester said, there is no such event.

But you can register a custom click listener that handles the click of the button in the screenshot

AJS.$("#create-dialog .create-dialog-create-button").click(function () { 
    console.log("Clicked 'Create' page button", this);
});

#5

@ppasler, @danielwester, thanks for the quick replies.
Yes, I dont need PageCreateEvent. I need to catch the event when the “create” button I showed in my snapshot is clicked and the editor is opened. After that, I intend to go over the editor’s storage format and do some manipulation on that .

I can try the JS option @ppasler suggested, but I am very unsure, if I can get the handle of the editor’s storage format from the front end like that. Please advise.


#6

Seems like you want to do something, when the editor finished loading, right? The manipulations should be done directly after editor loading or before saving the page?


#7

@ppasler, yes, the manipulatons should be done directly after the editor loads.


#8

Ok, then this should do the job

// wait for editor to be loaded
AJS.bind("rte-ready", function () {
	// do manipulations
});

Note that this event is also thrown if the editor for comments is loaded.
You might check for this classes to differ page edits and comments $(".contenteditor.edit")