以下代码剪切应从服务器获取一个键/值对,并根据JSON数据创建选项卡。
$(function() {
//data from server is key value pairs of id,name
$.getJSON('/getdata', function(result){ // <-- problems
$.each(result, function(id, name){
$("#profile").tabs( "add", '#profile-'+id, name );
// ...
// do some additional work to populate the tab pane's content
// ...
});
});
});
在jQuery UI 1.7.x系列中,这将创建选项卡,并且可以单击(当然,窗格中没有数据)。在1.8.x系列中,选项卡显示但无法单击。如果我使用原始数组而不是getJSON行,它可以在两者中使用。我使用jQuery 1.4.4,1.5.1和1.5.2对此进行了测试。有线索吗?