ReferenceError: $ is not defined

-1

Hello, I created an application a short time ago and got jquery via Nuget, but it gets error starting jquery. I have the following function in a js file.

$("#myNav").bind("mousewheel", function (ev, delta) {
    var scrollTop = $(this).scrollTop();
    $(this).scrollTop(scrollTop - Math.round(delta));
}); 

And my Layout has the following HTML

<!DOCTYPE html>
<html>
<head>
    <script src="~/Scripts/View/Layout.js" type="text/javascript"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DK Design - @ViewBag.Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</head>
<body>
    <div>
        <div class="navbar navbar-light bg-light">
            <table style="width:100%">
                <tbody>
                    <tr>
                        <td align="right" valign="top" width="1%">
                            <button type="button" class="navbar-toggler" onclick="ControlNav()">
                                <span class="navbar-toggler-icon"></span>
                            </button>
                        </td>

                        <td align="center" width="90%">
                            <h1 class="logoFont">DK DESIGN</h1>
                        </td>

                        <td align="left" width="9%">
                            <span>Login </span><span> | </span><span> Registro</span>
                        </td>
                    </tr>
                </tbody>
            </table>

            <div id="myNav" class="overlay">
                <!-- Overlay content -->
                <div class="overlay-content">
                    @Html.ActionLink("Home", "Index", new { controller = "Home" }, new { @class = "font-custom-color" })
                    @Html.ActionLink("Contet Test", "Index", new { controller = "ContentTest" }, new { @class = "font-custom-color" })
                    <a href="#">Clients</a>
                    <a href="#">Contact</a>
                </div>

            </div>
        </div>
    </div>
    <div>
        @RenderBody()
    </div>

    <hr />
</body>
</html>

And the Bundle looks like this:

using System.Web;
using System.Web.Optimization;

namespace DKDSGN
{
    public class BundleConfig
    {
        // Para obter mais informações sobre o agrupamento, visite https://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            // Use a versão em desenvolvimento do Modernizr para desenvolver e aprender. Em seguida, quando estiver
            // pronto para a produção, utilize a ferramenta de build em https://modernizr.com para escolher somente os testes que precisa.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/bootstrap.css",
                      "~/Content/site.css"));
        }
    }
}

I have tried to initialize the jquery before the function, but it will not .. I tried to reference the files by src but it did not work, could anyone help me?

    
asked by anonymous 31.12.2018 / 00:45

1 answer

0

Place this at the end of the View in this order:

--omitido
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
    <script src="~/Scripts/View/Layout.js" type="text/javascript"></script>
</body>
</html>

Check out the chrome developer tools if the files were uploaded:

If possible send a print of the directories of your solution.

    
31.12.2018 / 15:27