Если вы хотите переопределить кнопку на ленте. Создание пользовательского компонента страницы - хорошая идея. Пример:
Type.registerNamespace('Company.Project.Ribbon.PageComponent');
Company.Project.Ribbon.PageComponent = function (PageComponentId) {
this._pageComponentId = PageComponentId;
Company.Project.Ribbon.PageComponent.initializeBase(this);
}
Company.Project.Ribbon.PageComponent.prototype =
{
_pageComponentId: "PageComponentIDHolder",
getId: function () {
return this._pageComponentId;
},
init: function () {
this._myCommandList = ['DownloadCopy'];
this._myHandledCommands = {};
this._myHandledCommands['DownloadCopy'] = Function.createDelegate(this, this.CMD1_Handler);
},
getFocusedCommands: function () {
return this._myCommandList;
},
getGlobalCommands: function () {
return this._myCommandList;
},
canHandleCommand: function (commandId) {
var canHandle = this._myHandledCommands[commandId];
if (canHandle)
return true;
else
return false;
},
handleCommand: function (commandId, properties, sequence) {
return this._myHandledCommands[commandId](commandId, properties, sequence);
},
isFocusable: function () {
return true;
},
CMD1_Handler: function (commandId, properties, sequence) {
alert('Download a copy-button was clicked');
}
}
Company.Project.Ribbon.PageComponent.registerClass('Company.Project.Ribbon.PageComponent', CUI.Page.PageComponent)
NotifyScriptLoadedAndExecuteWaitingJobs("/_layouts/custompagecomponents/PageComponent.js");
function init2() {
var instance = new Company.Project.Ribbon.PageComponent("ComponentID");
SP.Ribbon.PageManager.get_instance().addPageComponent(instance);
}
function init1() {
ExecuteOrDelayUntilScriptLoaded(init2, 'sp.ribbon.js');
}
ExecuteOrDelayUntilScriptLoaded(init1, '/_layouts/custompagecomponents/PageComponent.js');