ドロップダウン メニューを生成するコードと、ユーザーが選択したものに基づいて 2/4/8 というドロップダウンがあり、その数のドロップダウンが作成されます。
テンプレートコードは次のとおりです。
div.row.hidden#rowTemplate
label.control-label(for="team") Team:
div.controls
select#team1(style='width: 160px;')
include teamsDropDown
ドロップダウンを生成する JS は次のとおりです。
スクリプト (タイプ = 'テキスト/javascript')
$("#nTeamSelector").change(function(){
var nTeams = $("#nTeamSelector").val(); // Get the value of the team selector that you use
$("#rowContainer").empty() // Delete all existing dropdowns
for (var i=0; i<nTeams; i++){
var newRow = $("#rowTemplate").clone(); // Exact copy of the element generated by Jade
/*
* here you should change all the little fields that
* make the dropdowns different. For example:
*/
//newRow.children(".control-label").setText("Team "+(i+1)+":");
newRow.attr('id', 'team'+(i+1)+'Row');
newRow.removeClass("hidden");
$("#rowContainer").append(newRow);
}
});
現時点ではsetText
、エラーが発生するため、回線を機能させることができませんUncaught TypeError: Object [object Object] has no method 'setText'
。これに加えて、生成されたすべてのドロップダウンには、rowTemplate コードから引き継がれた があり、生成された各ドロップダウンのチームになるようにこれを追加したいとselect
思いid
ます。#team1
i
何か案は?