加載時,兩個事件被觸發,但未註冊到指定的事件處理程序。未表現的代碼是:
$("#calendar_menu_item").bind('click', loadCalendarContent());
$("#patient_menu_item").bind('click', loadPatientContent());
這是整個腳本:
/* Add stuff only once the DOM is loaded. */
$(document).ready
(
function(){
//Initialize the main menu
var menuItems = [$("#calendar_menu_item"), $("#patient_menu_item")];
for (i = 0; i < menuItems.length; i++) {
var menuItem = menuItems[i];
menuItem.bind('mouseover', function(){
$(this).css("background-color", "#749ccf");
});
menuItem.bind('mouseout', function(){
$(this).css("background-color", "#506077");
});
}
$("#calendar_menu_item").bind('click', loadCalendarContent());
$("#patient_menu_item").bind('click', loadPatientContent());
}
);
function loadCalendarContent(){
$("#content_area").load('calendar.html');
}
function loadPatientContent(){
$("#content_area").load('patient.html');
}
function doAction(){
alert("in doScript()");
}
感謝Alxandr。 – 2011-01-28 00:50:04