jeudi 2 juin 2016

Script not loading

Hi guys i am losing a lot of time on a problem that might be easy, and i bet it is a simple thing, so in the layout.cshtml i load all my scripts like this

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                    <li>@Html.ActionLink("Contact", "Contact", "Home")</li>
                </ul>
                @Html.Partial("_LoginPartial")
            </div>
        </div>
    </div>
    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
        </footer>
</div>

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

the scripts that are in this page are loaded in the buldeconfig like this:

 public class BundleConfig
{
    // For more information on bundling, visit http://ift.tt/186MuSj
    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*"));

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

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

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

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

a strange thing is happening i jquery code on the CrowdTouring.cs that should be aplied for 2 pages, my register and my edituser, in the register it is working it disables a button, but in my EditUser it doesnt work and i dont know why i already tryed everything :S

Here is my Jquery CrodwTouring.js

$(document).ready(function () {
$("#checky").click(function () {
    $("#RegisterBut").attr("disabled", !this.checked);
});

$("#TipoUtilizador").change(function () {
               console.log("a");
    if ($(this).val() == "Cliente") {
        $("#TextoTipoUtilizador").text('Crie desafios de inovação turística e obtenha melhores soluções a um preço mais acessível e de melhor qualidade');
    }
    if ($(this).val() == "Resolvedor") {
        $("#TextoTipoUtilizador").text('Crie Soluções para os desafios e obtenha uma grande variadade de prémios');
    }
    if ($(this).val() == "Avaliador") {
        $("#TextoTipoUtilizador").text('Avalie as soluções e ganhe notoriedade na plataforma');
    }
});

$("div.myclass").hover(function () {
    $(this).css("background-color", "red")
});

function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();

        reader.onload = function (e) {
            $('#fotografia').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

$("#ImagePath").change(function () {
    console.log("x");
    readURL(this);
});

});

Finally in my editUser page i load the scripts like that on the bottom

 <div class="form-group">
        <div class="col-md-offset-3 col-md-9">
            <input type="submit" value="Save" class="btn btn-default" />
        </div>
    </div>
</div>

}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/bundles/UserScripts")
}

Aucun commentaire:

Enregistrer un commentaire