i want to hide sharepoint 2010 list/library context menu based on users.
i am using below javascript
$(document).ready(function(){
$('.ms-MenuUIPopupBody').live('blur', function() {
var elm = $("div.ms-MenuUIULItem a:contains('View in Browser')");
elm.remove();
$("div.ms-MenuUIULItem a:contains('Edit in Browser')").remove();
});
});
It is hiding menu only on focus or blur or mouse-over on the context menu.
the context menu is generating dynamically by core.js file
i need to add the script when the context menu is created.
so i need to find the event for context menu
how to find the click event and add my custom code.
with "Andrew" i found good solution and to handle the context menu event
var _MenuHtc_show;
function OverrideMenuHtc_show()
{
_MenuHtc_show = window.MenuHtc_show;
window.MenuHtc_show= function (m,r,fr,ft,yoff) {
_MenuHtc_show(m,r,fr,ft,yoff);
var elm = $(".ms-MenuUIULItem[text='Alert Me']");
elm.remove();
};
}
ExecuteOrDelayUntilScriptLoaded(OverrideMenuHtc_show, "core.js")
its working fine but its hiding context menu for all webparts. i need to find the context menu selected webpart id to check is it right webpart to hide context menu.
i am able to find the webpart id after once i select webpart with this code.
var listId = SP.ListOperation.Selection.getSelectedList();
or
var ctxCur = GetCurrentCtx();
var SPGridViewGuid = ctxCur.listName;
but if i click on "v" symbol with out selecting the webparts its return null.
is there any way to find the context menu selected webpart id. so its solves my problem.