This Durandal 2 knockout markup generates tabs with appropriate content but no tab is marked active.
<div id="editor" class="html-editor form-control" contenteditable="true" data-bind="html: Content"></div>
<label>Questions</label>
<div class="question-container navbar">
<ul class="nav nav-tabs" id="Questions" data-bind="foreach: Questions">
<li role="presentation">
<a data-toggle="tab" data-bind="text: Caption, attr: { href: '#' + QuestionId }"></a>
</li>
</ul>
<div class="tab-content Questions" data-bind="foreach: Questions">
<div class="tab-pane well" data-bind="attr: { id: QuestionId }">
<div class="html-editor form-control" contenteditable="true" data-bind="html: Question"></div>
<div data-bind="foreach: Answers">
<div class="input-group">
<textarea class="form-control" data-bind="value: Caption"></textarea>
<span class="input-group-addon">
<input type="radio" aria-label="Correct answer" data-bind="checked:isCorrect" />
</span>
</div>
</div>
</div>
</div>
</div>
In static markup one would identify the initially active tab by marking it with CSS class active
.
How would one do that when all the tabs are generated?
This is Durandal 2 so I could handle attached
and manipulate the DOM using jQuery.
What is the recommended approach?