我创建了一个jquery ui选项卡,我想要做的是当包含jquery ui选项卡的页面加载时,将打开特定选项卡取决于上一页。到目前为止,我有以下几点:
PHP:
使用Javascript:
然后我不太确定怎么做才能让它在$('#tabs')中工作。制表符({....声明。如何解决这个问题的任何想法将非常感谢。非常感谢。< / p>
PHP:
$string = $_SERVER['HTTP_REFERER'];
$string = substr($string, -(strlen($string)-strrpos($string, '/')-1), strlen($string)-strrpos($string, '/'));
if ($string == "specific_page.php") {
$tab_index = 2;
} else {
$tab_index = 0;
}
HTML:
...
<input id="hidden_input" type="hidden" value="<?php echo $tab_index; ?>" />
JS:
$(document).ready(function() {
var tab_index = $('#hidden_input').attr('value')
$('#tabs').tabs({ cache:false,
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible.");
}
},
...something here for tab selection?...
});
});
答案 0 :(得分:0)
您可以使用
定义活动标签$(".selector" ).tabs({active: 2 });
意思是,如果我正确理解你的tab_index,那么你的代码就是。
$('#tabs').tabs({
cache: false,
active: tab_index,
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html("Couldn't load this tab. We'll try to fix this as soon as possible.");
}
},
...something here for tab selection?...
});