Document.ready无法在我的登录页面上工作

时间:2013-07-24 18:53:33

标签: c# javascript asp.net-mvc

所以,我有这个登录页面(见下面的代码),Document.ready无效。是脚本中的问题吗?我的代码中是否会出现使document.ready无法正常工作的内容?

我试图通过我的javascript中的提醒消息进行检查,但它们永远不会被点击。

@model OpenRoad.Web.Areas.Account.Models.LogOnModel
@using Combres.Mvc
<!doctype html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!-->
<html class="no-js" lang="en">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>@string.Format("{0} - {1}", OpenRoad.Web.ApplicationSettings.Title, "Logon")</title>
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="shortcut icon" href="/Content/images/favicon.ico" />

@Html.CombresLink("siteCss")
<link rel="stylesheet" type="text/css" href="@Url.Content("~/App_Themes/" +       OpenRoad.Web.ApplicationSettings.Theme + "/styles.css")" />    
 </head>
 <body class="login">

@{
     ViewBag.Title = "Log On";
}
@section scripts {
<script type ="text/javascript">
    $(document).ready(function () {
        alert('test');
        mixpanel.track("View Logon");
        if ($(".validation-summary-errors")[0]) {
            alert('Found with Length');
        };
    });
 }   
</script>

1 个答案:

答案 0 :(得分:1)

假设你的_Layout.cshtml有这个:

     @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

将@section脚本更改为@section Scripts

相关问题