Hide Menu Tab

1

I'm trying to hide the nav menu bar when it enters a specific form, would you like to give some example?

Thisistheindexofmyform:

@usingPagedList.Mvc;@modelPagedList.IPagedList<BlogWeb.Models.Abastecimento><!DOCTYPEHTML><p>@Html.ActionLink("Novo Abastecimento ", "Form")</p>
@Html.ActionLink("Gerar Relatório Resumo", "PeriodoResumo")

<div>
    <table id="customers">
        <thead>
            <tr>
                <th>Nº do Carro</th>
                <th>Data</th>
                <th>Km</th>
                <th>Produto</th>
                <th>Litro</th>
                <th>Valor Unitario</th>
                <th>Valor Total</th>
                <th>Usuario</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var a in Model)
            {
                <tr>
                    <td>@a.NumCarro.NCarro</td>
                    <td>@a.DtAbastecido</td>
                    <td>@a.Km</td>
                    <td>@a.Produto.NomeProduto</td>
                    <td>@a.Litro</td>
                    <td>@a.VlrUnit</td>
                    <td>@a.TotalGasto</td>
                    <td>@a.Autor.Nome</td>
                    <td>@Html.ActionLink("Remover", "Remove", new { id = a.Id }, new { @class = "icon-cancel" })</td>
                    <td>@Html.ActionLink("Atualizar", "FormUpdate", new { id = a.Id }, new { @class = "icon-edit" })</td>

                </tr>
            }
              @Html.ActionLink("Gerar Relatório por Período","FormData")
       </tbody>
    </table>
</div>
<div class="static">
    Página @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) de @Model.PageCount
</div>
        @{
            if (Model.TotalItemCount != Model.Count)
            {
                    <div class="pagination-lg">

                        @if (Model.HasPreviousPage)
                        {
                            @Html.ActionLink("<<", "Index", new
                       {
                           pagina = 1,
                           sortOrder = ViewBag.CurrentSort,
                           currentFilter = ViewBag.CurrentFilter
                       })
                            @Html.Raw(" ");
                            @Html.ActionLink("< Anterior", "Index", new
                      {
                          pagina = Model.PageNumber - 1,
                          sortOrder = ViewBag.CurrentSort,
                          currentFilter = ViewBag.CurrentFilter
                      })
                        }
                        else
                        {
                            @:<<
                            @Html.Raw(" ");
                            @:< Anterior
                           }

                        @if (Model.HasNextPage)
                        {
                            @Html.ActionLink("Próxima >", "Index", new { pagina = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
                            @Html.Raw(" ");
                            @Html.ActionLink(">>", "Index", new { pagina = Model.PageCount, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter })
                        }
                        else
                        {
                            @:Próxima >
                            @Html.Raw(" ")
                            @:>>
                   }
                    </div>

            }
        }

This is my layout:

    <!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Ribeira</title>
    <link href="~/Content/Css/normalize.css" rel="stylesheet" />
    <link href="~/Content/Css/blog.css" rel="stylesheet" />
    <link href="~/Content/Css/fontello-codes.css" rel="stylesheet" />
    <link href="~/Content/Css/fontello.css" rel="stylesheet" />
</head>
<body>
    <nav>
        <ul>
            <li>@Html.ActionLink("Home","Index","Home")</li>
            <li>@Html.ActionLink("Post","Index","Post")</li>
            <li>@Html.ActionLink("Usuario", "Index", "usuario")</li>
            <li>@Html.ActionLink("Plano Ação", "Form", "ItemPlanoAcao")</li>
            <li>@Html.ActionLink("Veiculos", "Form", "Veiculo")</li>
            <li>@Html.ActionLink("Rota", "Index", "Rota")</li>
            <li>@Html.ActionLink("Abastecimento", "Index", "Abastecimento")</li>
            <li>@Html.ActionLink("Fornecedores", "Index", "Fornecedores")</li>
            <li>@Html.ActionLink("Compra", "Index", "Compra")</li>
            <li>@Html.ActionLink("Estoque", "Index", "Estoque")</li>
            <li>@Html.ActionLink("Visita", "Index", "Visita")</li>

        </ul>
    </nav>
    <header>
        <h1>
           Ribeira Beer Distribuidora de Bebidas Ltda
        </h1>
        <p>
            Descricao
        </p>
    </header>
    <div class="conteudo"> 
        <main>
            @RenderBody()
        </main>
        @Html.Action("Index","Menu")
    </div>

    <footer>
        Copyright 2017 - RibeiraBeer
    </footer>
    @RenderSection("Scripts",false)
</body>
</html>
    
asked by anonymous 29.05.2018 / 13:19

2 answers

2

Guilherme, you can use pure JavaScript. Just put the script anywhere on the page where you want to hide nav :

<script>
// dispara a função quando os elementos do DOM foram carregados
document.addEventListener("DOMContentLoaded", function(){
   // seleciona a tag nav e aplica o estilo display: none (fica oculto)
   document.querySelector("nav").style.display = "none";
});
</script>
    
29.05.2018 / 15:57
2

If it is when you enter another page you can hide this nav with jquery:

$(document).ready(() => {
  $('#idNav').css('display', 'none');
})
    
29.05.2018 / 13:37