I need to display a confirm popup when page is published to warn about unpopulated publishing page fields. User might contiune in which case page will be published, or user might cancel publishing.
I have some TextField publishing fields on a layout page. Users want a warning on publishing but they are not requirede fields as users might decide to leave them empty. The solution requires a confirm pupup.
I have been investigating replacing publish button in the ribbon with a custom one but replacing looses the original publish logic. I don't want a hack like copying the CommandAction from existing XML.
One thing I considered was replacing the publish button and in CommandAction showing a confirm and if OK have client script to call the publish command like:
var instance = SP.Ribbon.PageManager.get_instance(); if (instance) instance.get_commandDispatcher().executeCommand(commandName, optionalPropertyBag);
However, this must work from ribbon as well as page library context menu dropdown on an item. I am not sure whether to replace the publish button and use this kind of client logic is the right thing for this.
My question is: Is there a way of adding custom commands and attaching it to existing buttons. Is it possible to simply attach a script to a button without replacing so that it returns first and depending on the return the rest fires.
I mean something similar to ASP.NET button clientClick running and returning and Click firing depending on the result.
I am simply trying to add a confirm to existing logic.