I am trying to override a sharepoint call out in a document library. So far, I was able to add a link to the footer using this javascript:

SP.SOD.executeFunc("callout.js", "Callout", function () {
    var itemCtx = {};
    itemCtx.BaseViewID = 'Callout';
    itemCtx.Templates = {};
    itemCtx.Templates.Footer = function(itemCtx) {
        var calloutID = GetCalloutElementIDFromRenderCtx(itemCtx);
        var itemId = itemCtx.CurrentItem.ID;
        var listId = itemCtx.listName;
        var listUrl = itemCtx.listUrlDir;
        var customFooter = [];
        var someUrl = "some url";
        var link = "<a href='#' onclick='OpenPage(\""+someUrl+"\")'>Click Me</a>";

        customFooter.push('<span id=' + StAttrQuote(calloutID + '-ecbMenu') + 'class="js-callout-actions js-callout-ecbActionDownArrow">');
        customFooter.push(RenderECBinline(itemCtx, itemCtx.CurrentItem, itemCtx.CurrentFieldSchema));
        return Callout.GenerateDefaultFooter(calloutID, customFooter.join('')); 
    itemCtx.ListTemplateType = 101;

function OpenPage(myurl) {
    // navigate to the url
    //window.location.href = myurl;

    // open in a new window

I also want to increase the size of the callout to the maximum of 610px, but I am not sure how to override it. I have seen examples of creating a new callout and setting the size, but nothing about existing callouts associated with a document library. Any help is appreciated.

  • Where we need to add this .js file, in allitems page? Also will it work in SP 2016? – Amay Kulkarni Mar 5 '19 at 14:39

You can increase the "default" content width by setting the variable Strings.STS.L_DocLibCalloutSize, just change it after strings.js is loaded.

Strings.STS.L_DocLibCalloutSize = "610"

It is defined in clienttemplates.js, worst case you'll have to override the entire function; function OpenCallout(launchPoint, curEvent, node, listItemID) {...

If you take a look in the function the create part looks like this:

listCallout = CalloutManager.createNew({
      launchPoint: launchPoint,
      ID: calloutID,
      openOptions: {
        event: "none",
        showCloseButton: true,
        closeCalloutOnBlur: true
      onOpeningCallback: function(callout) {
         Callout_OnOpeningCallback(callout, listItemID);
      onOpenedCallback: function(callout) {
      beakOrientation: "leftRight",
      onClosedCallback: ecbManager.DismissECB,
      contentWidth: parseInt(Strings.STS.L_DocLibCalloutSize),
      boundingBox: document.getElementById('s4-workspace')

Update for iframe width:

Tbh I'm not sure about this approach, but you don't have to override anything, maybe you find a better solution. But you'll atleast see how it could work:

$(".ms-list-itemLink").each(function(e,i)  { 

    $(this).click(function() {
        var self = this;
        var checkExist = setInterval(function() {
            if(CalloutManager.isAtLeastOneCalloutOpen()) {

                CalloutManager.forEach(function(i) {

                    if(i.isOpen()) {            




        }, 100);

  • Thanks! That set the callout window to 610, but the content width is still the default. Is it possibly to override that also, or will I have to create a new callout. I have the code to do a new callout from a link on a page, but I don't know how to trigger it from a list item. – steveareeno May 31 '16 at 13:01
  • I am going to mark this as the answer. Although I haven't yet been able to increase the content width, part of that is due to the callout display a office web apps document preview, which requires, as far as I can tell, creating an iframe and setting it's size. – steveareeno May 31 '16 at 13:25
  • @steveareeno updated my answer, but like I say, I'm not sure about if there is "nicer" way of doing it without overriding the function. – Anders Aune May 31 '16 at 14:15
  • the update work on the first click but not subsequent. I will take what you have provide and keep working on it. I appreciate all you time and you have me pointed in the right direction I believe – steveareeno May 31 '16 at 18:29
  • @steveareeno remove the $(self).unbind("click"); , didn't test it, looks like it renders the content again :) – Anders Aune Jun 1 '16 at 5:46

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.