locked
How to disable menu item based on the output from Jquery function RRS feed

  • Question

  • User1632102518 posted

    I have the following menu items in Layout.cshtml as below.

     <ul>                   <li><a href="/Hadoop/Jobs" style=";z-index:1">Jobs</a></li>
                            <li><a href="/Hadoop" style=";z-index:1">Hadoop Source</a></li>                        
                            <li><a href="/Hadoop/mapDataDictionary" style=";z-index:2">Map Data</a></li>
                            
     </ul>

    What I would like to do is, show/hide "Map data" menu item based on the output from a Jquery function CheckUser(thats checks whether the user is authenticated or not ).

    Thursday, November 12, 2015 5:56 PM

Answers

  • User61956409 posted

    Hi sreeja1234,

    What I would like to do is, show/hide "Map data" menu item based on the output from a Jquery function CheckUser(thats checks whether the user is authenticated or not ).

    Please refer to the following sample code to dynamically show/hide item.

    function CheckUser() {
        if (authenticated) {
            $("ul li a[href='/Hadoop/mapDataDictionary']").parent().show();
        } else {
            $("ul li a[href='/Hadoop/mapDataDictionary']").parent().hide();
        }
    }
    

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 12, 2015 9:20 PM