Hack 1: Overriding link on mouseenter
In the end I resorted to the following hack:
// requires jQuery
$(document).ready(function() {
$("#WebPartWPQ1").on("mouseenter", "a[evtid='new_item']", function(evt) {
var $link = $(this);
$link.unbind(); // Unbind any standard sharepoint event handlers
$link.attr("href", "http://linkToMyCustomForm");
});
}
where #WebPartWPQ1
is the calendar webpart's container ID.
This snippet registers when the mouse is moved over the "new item link" inside the webpart and replaces the link target with the custom link.
The problem of this solution is that the currently displayed date in the calendar view does not get propagated to the form.
Alternative: Using the obfuscated javascript "API"
function(instanceId, link) {
// wellknown object provided by sharepoint.
// It's the very last javascript callback after loading and initializing the page
// This ensures that the CalendarInstanceRepository has been initialized
window.Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function(){
window.SP.UI.ApplicationPages.CalendarInstanceRepository
.$w[instanceId] // $w - member with the internal array of registered calendar views
.$B_1 // $B_1: - instance of SP.UI.ApplicationPages.CalendarNewFormDialog
.$4w_1 = link; // $4w_1 - new item link property
});
};
where instance Id would be set to WPQ1
for example.