我在asp.net webforms页面上使用手风琴控件(使用母版页...),在我正在加载手风琴的内容后,我不会初始化。页面肯定有对jquery和jquery-ui文件的引用(当我有静态内容时它可以正常工作)。它崩溃的地方是我尝试通过ajax调用加载它...
主页标题:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
我的aspx页面标记:
<asp:content id="Content3" runat="Server" contentplaceholderid="mainContent">
<script type="text/javascript" src="Scripts/Catalog.aspx.js"></script>
<script type="text/javascript">
$(document).ready(Catalog.InitPage);
</script>
<div id="accordion" style="width: 850px;"></div>
</asp:content>
javascript(在单独的文件中,如果它在页面上的全部内容,则表现相同):
Catalog = {
BuildAccordion: function (results) {
var accordion = $('#accordion');
$.each(results.d, function (index, category) {
$(accordion).append('<div>' + category.CategoryName + '</div>');
$.each(category.Courses, function (index, courseItem) {
// will be adding more content here once it's all working...
});
});
Catalog.InitAccordion();
},
InitAccordion: function() {
$('#accordion').accordion({
active: false,
collapsible: true,
heightStyle: 'content'
});
},
InitPage: function () {
$.ajax({
type: "POST",
url: "WebServices/GlobalWM.asmx/GetCourseCatalog",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: Catalog.BuildAccordion
});
}
};
当页面运行时,我得到手风琴的内容ok,但我得到的错误是
TypeError: $(...).accordion is not a function
(来自InitAccordion函数的第一行......)手风琴不是手风琴。我错过了什么?