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.

  • I don't want to hide the existing Publish button and copy the appearance etc from the UI xml file and write code to call object model directly without using the command infrastructure. To start with, when publish is clicked the command UI framework asks user whether to publish major or minor version and user can enter comments and this internal SharePoint behaviour and the UI elements are all specific to the way Publish UI command works which is different to the object model. The best solution would be to be able to just hook to the handler. Jul 17 '12 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.