javascript函数在MVC项目下不起作用

时间:2015-02-14 21:22:34

标签: javascript jquery .net model-view-controller

函数rangeChanged不起作用。 alert函数也不起作用。如果我删除变量callbackRangeCalendar,则alert正在运行。

代码是否以不同的方式在MVC中编写?

如何解决此问题?

@{
    ViewBag.Title = "Home Page";
}

@section PageScripts{
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>



<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.7.0/moment-with-langs.min.js"></script>

<script type="text/javascript" src="@Url.Content("~/Content/calendar/js/jquery.rangecalendar.js")"></script>

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

<link rel="stylesheet" id="rangecalendar-style-css" href="@Url.Content("~/Content/calendar/css/rangecalendar.css")" type="text/css" media="all">
<link rel="stylesheet" id="rangecalendar-style-css" href="@Url.Content("~/Content/calendar/css/style.css")" type="text/css" media="all">

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/smoothness/jquery-ui.css">


<script type="text/javascript">
    $(document).ready(function () {

        var callbackRangeCalendar = $("#cal").rangeCalendar({ theme: "full-green-theme", lang: "tr", changeRangeCallback: rangeChanged, weekends: false });
        alert("ddddd");

        function rangeChanged(target, range) {


            console.log(range);
            var startDay = moment(range.start).format('DD');
            var startMonth = moment(range.start).format('MMM');
            var startYear = moment(range.start).format('YY');
            var endDay = moment(range.end).format('DD');
            var endMonth = moment(range.end).format('MMM');
            var endYear = moment(range.end).format('YY');


            $(".calendar-values .start-date .value").html(startDay);
            $(".calendar-values .start-date .label").html("");
            $(".calendar-values .start-date .label").append(startMonth);
            $(".calendar-values .start-date .label").append("<small>" + startYear + "</small>");
            $(".calendar-values .end-date .value").html(endDay);
            $(".calendar-values .end-date .label").html("");
            $(".calendar-values .end-date .label").append(endMonth);
            $(".calendar-values .end-date .label").append("<small>" + endYear + "</small>");
            $(".calendar-values .days-width .value").html(range.width);
            $(".calendar-values .from-now .label").html(range.fromNow);

        }

        function ragneChanged(target, range) {

            console.log(range);
        }

    });
</script>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
}

<div class="jumbotron">
    <h1>ASP.NET</h1>
    <p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
    <p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more &raquo;</a></p>
</div>


<dir class="col-md-12">
    <div class="section">
        <div id="cal">
        </div>
    </div>
</dir>

1 个答案:

答案 0 :(得分:0)

问题是jquery冲突。索里。感谢。