JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<a class="btn" id="home-btn" data-toggle="modal" href="#myModal" >Tab 1 Button</a>
<a class="btn" id="profile-btn" data-toggle="modal" href="#myModal" >Tab 2 Button</a>
<div class="modal hide" id="myModal">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h3>A yodel for a Modal</h3>
</div>
<div class="modal-body">
<ul class="nav nav-tabs" id="main-tabs">
<li class="li-home"><a href="#home" data-toggle="tab">Home</a></li>
<li class="li-profile"><a href="#profile" data-toggle="tab">Profile</a></li>
</ul>
<div class="tab-content" id="tabs">
<div id="home" class="tab-pane">
<form id="tab-1-form">
<label>Home sweet home:</label>
<input name="home-input" id="home-input" type="text" class="input-medium" />
</form>
</div>
<div id="profile" class="tab-pane">
<form id="tab-2-form">
<label>Profile: who are you?:</label>
<input name="profile-input" id="profile-input" type="text" class="input-medium" />
</form>
</div>
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
JavaScript
$('#myModal').on('show', function () {
// http://stackoverflow.com/questions/48239/getting-the-id-of-the-element-that-fired-an-event-using-jquery
// are we working with "home" or with "profile"?
var theButtonCaller = event.target.id;
theButtonCaller = theButtonCaller.replace("-btn", "");
$(".tab-pane, #main-tabs li").removeClass("active");
$("#" + theButtonCaller).addClass("active");
$("#main-tabs li.li-" + theButtonCaller).addClass("active");
});
$('#myModal').on('shown', function () {
var theButtonCaller = event.target.id;
theButtonCaller = theButtonCaller.replace("-btn", "");
$("#" + theButtonCaller + "-input").focus();
});
$('a[data-toggle="tab"]').on('shown', function (e) {
// console.log( e.target ); // activated tab
var inputToFocus = $(e.target).attr("href");
inputToFocus = inputToFocus.replace("#", "");
$("#" + inputToFocus + "-input").focus();
});