我正在使用 jquery.ui 动态创建选项卡。此外,每个选项卡都有一些可扩展的内容,因此我想在创建每个选项卡时绑定正确的事件。
我正在使用上面的代码执行此操作。
$('.ui-tabs-panel #activity').livequery(function(){
$(this.getElementsByClassName('activity')).expandAll({
expTxt : "More",
cllpsTxt : "Less",
ref : "div.collapse"
});
});
编辑:我正在使用代码创建选项卡:
function addTab(title, customer) {
//alert("AddTab. Title: " + title + " Customer: " + customer);
$tabs.tabs( "add", "#tabs-" + tab_counter, title );
$("#tabs-" + tab_counter).attr("name", customer);
tab_counter++;
return tab_counter;
}
$tabs = $("#tabs").tabs({
tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
add: function( event, ui ) {
var tab_content = $tab_content_input.val() || "Tab " + tab_counter + " content.";
$( ui.panel ).append( "<p>" + tab_content + "</p>" );
}
});
问题是只有当我在标签名称中传递鼠标并且我希望我的 div 在创建标签时折叠时才会运行此代码。我想在创建选项卡时运行此代码。是否有任何实时查询事件?我在这里想念什么?