我對jquery比較新,所以接受答案可能很明顯。我有一個插件,它提供了一個功能,但是當我運行我的程序,我得到的控制檯錯誤:JQuery函數存在但說方法undefined
Cannot call method 'createEvent' of undefined
就像我說我可能已經錯過了一些東西簡單,但我不能找到什麼。 var desiredValue當然是檢索正確的數據,並且我確保插件在標題中正確鏈接。如果任何人有任何建議,他們可以給,這將非常感激!謝謝。
function createEvent(title,location,notes, startDate, endDate){
var title= "My Appt";
var location = "Los Felix";
var notes = "me testing";
var startDate = "2012-11-23 09:30:00";
var endDate = "2012-11-23 12:30:00";
cal.createEvent(title,location,notes,startDate,endDate);
}
var cal;
$(document).ready(function() {
cal = window.plugins.calendarPlugin;
$('.calinfo').live('click', function() {
var desiredValue = $(this).parent().prev().find('.calendar').val();
var calInfo = desiredValue.split(',');
createEvent(calInfo[0], calInfo[1], calInfo[2], calInfo[3], calInfo[4]);
});
});
是否定義了window.plugins.calendarPlugin? – 2012-08-09 02:47:58
你可以console.log(window.plugins.calendarPlugin)嗎?另外這個插件有兩個必需的框架,你包括那些? – Ohgodwhy 2012-08-09 02:48:39
@Ohgodwhy啊你熟悉的插件啊?是的,包括2個框架 – MeltingDog 2012-08-09 03:35:31