locked
How to change the text of (View Item & Edit Item) List Menu Items RRS feed

  • Question

  • hi,

    I want to change the text of View Item & Edit Item of List item Menu , below is the screenshot.

    Thanks


    sal

    Sunday, August 20, 2017 7:06 AM

Answers

  • Hi,

    Here is a Jquery code snippet for your reference:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    	var newItem1 = "View Item Changed";
        var newItem2= "Edit Item Changed";
        setInterval(ChangeText, 100);
    	
    	function ChangeText()
    	{
    	  var $t1 = $("ul.ms-core-menu-list li:contains('View Item')");
    	  $t1.find("span.ms-core-menu-title").text(newItem1);
    	  var $t2 = $("ul.ms-core-menu-list li:contains('Edit Item')");
    	  $t2.find("span.ms-core-menu-title").text(newItem2);
    	}
    </script>
    

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, August 21, 2017 10:07 AM
  • Hi,

    Please make sure the function is triggered with setInterval:

    setInterval(ChangeText, 100);
    

    If directly called by the function name normally, then it won't work, because ECB menu item won't load when page load:

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by SB Ali Tuesday, August 22, 2017 7:55 AM
    Tuesday, August 22, 2017 1:05 AM

All replies

  • Hi,

    Here is a Jquery code snippet for your reference:

    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
    <script type="text/javascript">
    	var newItem1 = "View Item Changed";
        var newItem2= "Edit Item Changed";
        setInterval(ChangeText, 100);
    	
    	function ChangeText()
    	{
    	  var $t1 = $("ul.ms-core-menu-list li:contains('View Item')");
    	  $t1.find("span.ms-core-menu-title").text(newItem1);
    	  var $t2 = $("ul.ms-core-menu-list li:contains('Edit Item')");
    	  $t2.find("span.ms-core-menu-title").text(newItem2);
    	}
    </script>
    

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, August 21, 2017 10:07 AM
  • hi,

    i tried the the above script using CEWP but it is not working , below is the screenshot of browser console.

    Thanks


    sal


    • Edited by SB Ali Monday, August 21, 2017 5:08 PM
    Monday, August 21, 2017 5:05 PM
  • Hi,

    Please make sure the function is triggered with setInterval:

    setInterval(ChangeText, 100);
    

    If directly called by the function name normally, then it won't work, because ECB menu item won't load when page load:

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by SB Ali Tuesday, August 22, 2017 7:55 AM
    Tuesday, August 22, 2017 1:05 AM
  • hi,

    Thanks , it is working and I used that script in my existing function which was for hiding list item menus

    below is the complete script.

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" 
    
    type="text/javascript"></script><script type="text/javascript">
    
    $(document).ready(hideECBMenuItem);
    function hideECBMenuItem(){
    
    $("div.ms-list-itemLink").click(function(){
    CoreInvoke('ShowECBMenuForTr', this, event);
    MenuItemSetter(); return false;
    });
    
    $("a.ms-lstItmLinkAnchor").click(function(){
    CoreInvoke('ShowECBMenuForTr', this, event);
    MenuItemSetter(); return false;
    });
    }
    
    function MenuItemSetter(){
    
    
    setTimeout("WorkingWithMenuMenuItem()",300);
    }
    
    function WorkingWithMenuMenuItem(){
    
    
    
    //Hide List Menus
    $("a[title='Workflows']").parent().hide();
    $("a[title='Compliance Details']").parent().hide();
    $("a[title='Shared With']").parent().hide();
    $("a[title='Export Contact']").parent().hide();
    $("a[title='Alert me']").parent().hide();
    $("a[title='Version History']").parent().hide();
    $("a[title='Delete Item']").parent().hide();
    $('hr').remove();
    
    
    //change List Menu Text
    var newItem1 = "View Contact";
    var newItem2= "Edit Contact";
    
    var $t1 = $("ul.ms-core-menu-list li:contains('View Item')");
     $t1.find("span.ms-core-menu-title").text(newItem1);
    var $t2 = $("ul.ms-core-menu-list li:contains('Edit Item')");
    $t2.find("span.ms-core-menu-title").text(newItem2);
    }
    </script>


    sal


    • Edited by SB Ali Tuesday, August 22, 2017 7:55 AM
    Tuesday, August 22, 2017 7:54 AM
  • hi,

    There is one issue , in paging list items the script is not working, like if I click on next arrow which is below , the list item menu which were hidden shows up and the text also changes to default ( View Item & Edit Item)

    Thanks


    sal

    Tuesday, August 22, 2017 1:20 PM