Search code examples
sharepointsharepoint-2007sharepoint-2010

Can I reset variable declared in core.js file using CEWP?


Can I declare variable in Core.Js file and assign value on any SharePoint page. Like putting CEWP on page and setting variable(residing in Core.js file) value dynamially?

I tried putting one variable in Core.js file, and in CEWP I reset value to x, but I am not getting x value in any function inside Core.js file. Let me know if this could happen, if yes than how?

Thanks,

Ashish Chotalia


Solution

  • My understanding is that if you modify core.js, you are in an unsupported state, so i cannot recommend you do that.

    http://blogs.msdn.com/b/sowmyancs/archive/2008/04/02/customization-of-core-js-file-in-sharepoint.aspx

    Could you explain what you are trying to do and there is probably a better way.

    UPDATE

    Do you know that AddDocLibMenuItems already has a hook in it, to allow it to be overridden

    function AddDocLibMenuItems(m, ctx)
    {
        if (typeof(Custom_AddDocLibMenuItems) !="undefined")
        {
            if (Custom_AddDocLibMenuItems(m, ctx))
                return;
        }
    

    If you defined a function Custom_AddDocLibMenuItems, you should be able to work without customising core.js