Blog posts tagged with 'SharePoint Development'

SharePoint Custom_AddListMenuItems and Custom_AddDocLibMenuItems Chaining

SharePoint developers know how to add custom actions to the list item menus (ECB) with JavaScript. We use the global functions Custom_AddListMenuItems and Custom_AddDocLibMenuItems. Nadeem Yousuf has written a great blog post here about how this can be used. So far so good, but what happens when multiple developers/solutions do this? Short answer: The last wins! To overcome this behaviour you can use this solution. It allows to create and run multiple implementations of Custom_AddListMenuItems and Custom_AddDocLibMenuItems:

(function () {
    if (typeof Custom_AddListMenuItems != 'undefined')
        var function_chained = Custom_AddListMenuItems;
    Custom_AddListMenuItems = function (m, ctx, url) {

        // ADD ITEMS ****************************
        CAMOpt(m, "Hello World", "alert('Hello World')", "");

        if (function_chained === undefined)
        return function_chained(m, ctx, url);