3

I have one HTML button to to submit on one custom page layout. I want to to submit or publish this page on this HTML button click. I tried with binding it with ribbon button onclick using jquery. But its not working. Anybody has any idea how to achieve this?

2
  • Have you tried using JQuery to simulate clicking the ribbon button? $("#customButtonID").click(function(){$("#ribbonButtonID").click()});
    – Erin L
    Jan 15, 2016 at 13:50
  • yes... but it does not work. in this case. It works for other buttons on the page but not for buttons on the ribbon...!
    – Rajeev K
    Jan 16, 2016 at 4:26

1 Answer 1

8
+50

Check https://sharepoint.stackexchange.com/a/52877/35604:

<script type="text/javascript">
    function Custom_Submit(command)
    {
        SP.Ribbon.PageState.Handlers.showStateChangeDialog(command, SP.Ribbon.PageState.ImportedNativeData.CommandHandlers[command]);
    }
</script>
<input type="button" onclick="javascript:Custom_Submit('PageStateGroupPublish'); return false;" value="Publish" id="btnPublish"></input>

And quite the same for "Submit for approval" action, only change PageStateGroupPublish to PageStateGroupSubmitForApproval:

<script type="text/javascript">
    function Custom_Submit(command)
    {
        SP.Ribbon.PageState.Handlers.showStateChangeDialog(command, SP.Ribbon.PageState.ImportedNativeData.CommandHandlers[command]);
    }
</script>
<input type="button" onclick="javascript:Custom_Submit('PageStateGroupSubmitForApproval'); return false;" value="Submit" id="btnSubmit"></input>
6
  • its working for publish. I want to get it worked for Submit.
    – Rajeev K
    Jan 18, 2016 at 11:34
  • I edited my answer to add this case.
    – Evariste
    Jan 18, 2016 at 11:44
  • Do you have any idea about command ID for schedule button on the ribbon ? I checked that namespace but looks like its not listed there..! Please let me know if you have any idea about it. I have to have one custom button to schedule publication start date.!
    – Rajeev K
    Jan 24, 2016 at 7:28
  • Poping-up the Schedule window is another story, not related to the command handlers thing. Please, post a new question, and I'll try to find and answer it (add a comment here so I know).
    – Evariste
    Jan 24, 2016 at 11:02
  • Found it: to open the Schedule dialog, simply call Pub.Ribbon.PubCommands.schedule();.
    – Evariste
    Jan 28, 2016 at 17:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.