jQuery API を使用してタブを作成し、次のコードを使用して 2 番目のタブのクリック時に 1 つのイベント ハンドラーをバインドしました。
$('#tabs').bind('tabsselect', function(event, ui) {
refreshRemoveUI(event,ui);
});
function refreshRemoveUI(event,ui) {
if(ui.index==1){
$.get('FrontServlet?operation=getAllQues',function(data) {
var html = "";
var questionsNum = data.split(",");
if(questionsNum!="") {
html += '<br/><input type=checkbox name=removeAllQuestionId id=removeAllQuestionId onclick="toggleAll(this.checked)"/> Select/Deselect All<br/>';
for(var i=0;i<questionsNum.length;i++){
html += '<br/><input type=checkbox name=removeQuestionId id=removeQuestionId /> ' + questionsNum[i];
}
$('#remove').show();
} else {
$('#remove').hide();
html = 'No question available in quiz';
}
$('#removequestions').html(html);
});
}
}
私もajaxリクエストの完了時に同じバインドイベントを呼び出したいのですが、以下は私が試したものですが、うまくいきません:
$.get('FrontServlet?operation=remove&position='+val, function(data) {
$("#tabs li.ui-state-default:nth(1)").trigger("select");
});
アイデアはありますか?