0

How to call JavaScript in SharePoint Calendar Add Button Click event ?

4
  • What are you trying to do? You can hook into the button, for example with jQuery: $('[id="Ribbon.Calendar.Events.New.NewListItem-Large"]').click(function(){...}) or even override the methods directly in SP.UI.ApplicationPages.CalendarMouseHandler. But this will only tell you if the modal window were opened. You could however override the whole modal
    – eirikb
    Nov 6, 2012 at 6:56
  • $(document).ready(function () { $('.ms-acal-rootdiv').unbind("click").click(function () { .... }); }); i tried this but its not working Nov 6, 2012 at 6:59
  • $('[id="Ribbon.Calendar.Events.New.NewListItem-Large"]').click(function(){...})‌​ its also not working Nov 6, 2012 at 7:02
  • Note that will only trigger for the large button (hence "NewListItem-Large"). You can run that in console when you see the button. document ready will not work, as the Ribbon is loaded asynchronously.
    – eirikb
    Nov 6, 2012 at 7:18

1 Answer 1

1

What you could do instead is to use PreSaveAction. You need to append this to the form where you save the item, and run it like this when the form is ready:

function PreSaveAction() {
  // Do work;
  return shouldSaveItem;
}

For example (jQuery):

$(function() {
  window.PreSaveAction = function() { return false; };
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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