Project Online JSOM – Event handler for Save/Publish/any other buttons

Ever wonder when you wanted to have an event triggered when Save/Publish action is performed in Project Online.

Below JS could help you for save event. Similarly same code works for other buttons too.

Javascript:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
var attachSaveEvent = 
	setInterval(function(){
		if($("#Ribbon\\.Tabs\\.PDP\\.Home\\.Project\\.Save-Large").length == 1)
		{
			console.log("Done!!!");
			$('#Ribbon\\.Tabs\\.PDP\\.Home\\.Project\\.Save-Large').click(function(){
				console.log("Write your logic here");
			});
			clearInterval(attachSaveEvent);
		}
	},500);
</script>‚Äč