未捕获的TypeError:Object#<an object =“”>没有方法'fullCalendar'</an>

时间:2010-12-22 12:39:02

标签: javascript asp.net ajax jquery

我在我的asp.net mvc应用程序中嵌入了fullcalender控件。它在当地运行良好。但是当我将它上传到我的域服务器(第三方)时,它会显示给我

此错误:未捕获TypeError:对象#在crome控制台(调试器)中没有方法'fullCalendar'。而不是渲染控件。

** EDITED:  My HTML code is this **
“%&gt;

    指数     &lt;%var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); %GT; &LT; style type ='text / css'&gt;

body {
    margin-top: 40px;
    text-align: center;
    font-size: 14px;
    font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
    }

#calendar {
    width: 900px;
    margin: 0 auto;
    }

    &LT; script type =“text / javascript”&gt;

  $(document).ready(function() {
      var date = new Date();
      var d = date.getDate();
      var m = date.getMonth();
      var y = date.getFullYear();
      var officerid = document.getElementById('officerid').value;
      url = "/TasksToOfficer/Calender/" + officerid;

      var currenteventIden = <%= serializer.Serialize( ViewData["iden"] ) %>

      var calendar = $('#calendar').fullCalendar({
             header: {
                              left: 'prev,next today',
                              center: 'title',
                              right: 'month,agendaWeek,agendaDay',
                              border: 0
                          },

              eventClick: function(event, element) {

                                                      var title = prompt('Event Title:', event.title, { buttons: { Ok: true, Cancel: false} });
                                                      var iden = event.id;
                                                      if (title) {
                                                          var st = event.start;
                                                          var ed = event.end;
                                                          var aldy = event.allDay;
                                                          var dt = event.date;

                                                          event.title = title;                        
                                                          calendar.fullCalendar('updateEvent',event);


                                                          var date = new Date(st);
                                                          var NextMonth = date.getMonth() + 1;
                                                          var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();
                                                          var QueryStringForEdit=null;

                                                          QueryStringForEdit="officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=true&iden=" + iden;


                                                          if (officerid) {
                                                              $.ajax(
                                                                                            {

                                                                                                type: "POST",
                                                                                                url: "/TasksToOfficer/Create",
                                                                                                data: QueryStringForEdit,
                                                                                                success: function(result) {

                                                                                                    if (result.success) $("#feedback input").attr("value", ""); // clear all the input fields on success

                                                                                                },
                                                                                                error: function(req, status, error) {

                                                                                                }
                                                                                            });


                                                          }
                                                      }

                                                  },
          selectable: true,
          selectHelper: true,
          select: function(start, end, allDay) {
                                                  var title = prompt('Event Title:', { buttons: { Ok: true, Cancel: false }

                                                  }
                                                  );
                                                  if (title) {
                                                      calendar.fullCalendar('renderEvent',
                                                                                                                       {
                                                                                                                           title: title,
                                                                                                                           start: start,
                                                                                                                           end: end,
                                                                                                                           allDay: allDay
                                                                                                                       },
                                                                                                    false); // This is false , because do not show same event on same date after render from server side.
                                                      var date = new Date(start);

                                                      var NextMonth = date.getMonth() + 1; // Reason: it is bacause of month array it starts from 0

                                                      var dateString = (date.getDate()) + '/' + NextMonth + '/' + date.getFullYear();

        if (officerid) {
               $.ajax({                                                                                   type: "POST",
                                                                                                            url: "/TasksToOfficer/Create",
                                                                                                            data: "officerid=" + officerid + "&description=" + title + "&date=" + dateString + "&IsForUpdate=false",
                                                                                                            success: function(result) {

                                                                                                                if (result.success) $("#feedback input").attr("value", ""); 
                                                                                                                //$("#feedback_status").slideDown(250).text(result.message); 
                                                                                                            },
                                                                                                            error: function(req, status, error) {

                                                                                                            }
                                                                                                        });
                 }
                  }
                  calendar.fullCalendar('unselect');
            },
          editable: true,             
          events: url 
      });
  });

  //--------------------------------------------------------------------------//


</script >


<h2>
    Index</h2>
<div id="calendar">
</div>
<input id="officerid" type="hidden" value="<%=ViewData["officerid"].ToString()%>" />

alt text

alt text

2 个答案:

答案 0 :(得分:3)

您确定已将(正确的)javascript文件上传到外部服务器吗?不要相信Visual Studio的发布功能!

资源的网址是否正确?网址可以指向本地资源。

[编辑]

我唯一能想到的是,所以我会重复一遍。 我认为脚本的路径是错误的。

所以请再次检查。以下是否引用了这些文件?路径是否正确。 小心相对于您所在页面的路径! 使它们相对于域:即它们以'/'开头,并检查服务器上是否存在所有目录和文件。 确保在'fullcalendar.min.js'之前引用'jquery-1.4.4.min.js'或任何其他版本的jquery。

fullcalendar zip文件包含demo's ...检查那些......

否则我没有想法。

<link rel='stylesheet' type='text/css' href='/content/css/fullcalendar.css' />
<script type='text/javascript' src='/content/css/jquery-1.4.4.min.js'></script>
<script type='text/javascript' src='/content/css/fullcalendar.min.js'></script>

答案 1 :(得分:0)

试试这个:每次进入像eventClick这样的fullcalendar内部函数或对象时,请将calendar.fullcalendar替换为$(this).fullCalendar