Jquery tabs
官网
http://api.jqueryui.com/tabs/
必须通过了后台验证tab1的信息后才允许进入tab2
var passed=false;
$("#tabs").tabs({
event: "click",
active: 0,
beforeActivate: function (event, ui) {
if (ui.newTab.text() == "Tab2") {
$('#tabs-1 .validationMsg').hide();
var ok = true;
if (!passed ) {
ok = validate(); //前台validation
}
var toDo = function () {
passed = true;
$('#tabs').tabs("option", "active", 1);
//$('#tabs ul li:eq(1) a').focus();
}
var notToDo = function () {
passed = false;
var errorMsg = $('#tabs-1 .validationMsg').html();
// event.preventDefault();
// ui.oldTab.focus();
$('#tabs').tabs("option", "active", 0);
$('#tabs ul li:eq(0) a').focus();
setTimeout("$('#tabs-1 .validationMsg').html('" + errorMsg + "');$('#tabs-1 .validationMsg').show();", 0);
return;
}
if (!ok) {
event.preventDefault();
notToDo();
}
else {
if (!passed) {
validate2($('#tabs-1'), '/controller/action', toDo, notToDo); //后台ajax验证
event.preventDefault();
}
}
}
}
});