javascript 未捕获的类型错误:对象 #<an Object> 没有方法“fullCalendar”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4509237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Object #<an Object> has no method 'fullCalendar'
提问by Red Swan
I have embed the fullcalender control in my asp.net mvc application. It is running fine locally. but when I uploads it to my domain server (third party) it showing me
我已经在我的 asp.net mvc 应用程序中嵌入了 fullcalender 控件。它在本地运行良好。但是当我将它上传到我的域服务器(第三方)时,它会显示给我
This Error: Uncaught TypeError: Object # has no method 'fullCalendar' in crome console (debugger). and not rendering the control.
此错误:未捕获的类型错误:对象 # 在 crome 控制台(调试器)中没有方法“fullCalendar”。并且不呈现控件。
** EDITED: My HTML code is this **
" %>
Index <% var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); %> < style type='text/css'>
Index <% var serializer = new System.Web.Script.Serialization.JavaScriptSerializer(); %> <style type='text/css'>
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;
}
< script type="text/javascript">
<script type="text/javascript">
$(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()%>" />




回答by Steven K.
You're sure you've uploaded the (correct) javascript file to your external server? Don't trust Visual Studio's Publish feature for it!
您确定已将(正确的)javascript 文件上传到外部服务器?不要相信 Visual Studio 的发布功能!
Is the url to the resource correct? Url could point to a local resource.
资源的 url 是否正确?Url 可以指向本地资源。
[Edit]
[编辑]
There's only thing I can think of, so I'll repeat myself. I think that the path to the script is wrong.
只有我能想到的事情,所以我会重复自己。我认为脚本的路径是错误的。
So please check again. Are these files below referenced? Is the path correct. Be carefull with paths which are relative to the page you're on! Make them relative to the domain: i.e. they start with '/' and check all directories and files exists on the server. Make sure 'jquery-1.4.4.min.js' or any other version of jquery is referenced before 'fullcalendar.min.js'.
所以请再次检查。下面引用了这些文件吗?路径是否正确。小心相对于您所在页面的路径!使它们相对于域:即它们以“/”开头并检查服务器上存在的所有目录和文件。确保在 'fullcalendar.min.js' 之前引用了 'jquery-1.4.4.min.js' 或任何其他版本的 jquery。
The fullcalendar zip files contain demo's... check those...
fullcalendar zip 文件包含演示的...检查那些...
I'm out of ideas otherwise.
否则我没有想法。
<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>
回答by Jean Poulin
Try this: Every time you are inside an internal function or object of fullcalendar like your eventClick: replace calendar.fullcalendarby $(this).fullCalendar.
试试这个:每次你在像你这样的 fullcalendar 的内部函数或对象中时eventClick:replace calendar.fullcalendarby $(this).fullCalendar。

