1
我試圖在IPython筆記本中使用jQuery DataTables插件。出於某種原因,插件似乎不適用於jQuery實例。下面的代碼演示了這個問題。當我執行此操作時,出現錯誤「[Error] TypeError:'undefined'不是一個函數(評估'$('mytable')。dataTable')」在Web控制檯中,就好像該插件尚未加載。應該以這種方式加載插件嗎?無法在IPython筆記本中加載jQuery DataTables插件
from IPython.display import Javascript
Javascript('''
var dataSet = [
['Trident','Internet Explorer 4.0','Win 95+','4','X'],
['Trident','Internet Explorer 5.0','Win 95+','5','C'],
['Trident','Internet Explorer 5.5','Win 95+','5.5','A'],
['Trident','Internet Explorer 6','Win 98+','6','A'],
['Trident','Internet Explorer 7','Win XP SP2+','7','A'],
['Trident','AOL browser (AOL desktop)','Win XP','6','A'],
['Gecko','Firefox 1.0','Win 98+/OSX.2+','1.7','A'],
['Gecko','Firefox 1.5','Win 98+/OSX.2+','1.8','A'],
['Gecko','Firefox 2.0','Win 98+/OSX.2+','1.8','A'],
['Gecko','Firefox 3.0','Win 2k+/OSX.3+','1.9','A'],
['Gecko','Camino 1.0','OSX.2+','1.8','A']
];
$(element).html('<table id="mytable"></table>')
$('#mytable').dataTable({
"data": dataSet,
"columns": [
{ "title": "Engine" },
{ "title": "Browser" },
{ "title": "Platform" },
{ "title": "Version", "class": "center" },
{ "title": "Grade", "class": "center" }
]
});
''', lib=['/static/DataTables/media/js/jquery.dataTables.js'],
css=['/static/DataTables/media/css/jquery.dataTables.css'])
您是否最終會取得成功? – dmeu 2015-07-16 12:49:33