php - Open specific jquery ui tab based on which the previous page is -
i have created jquery ui tab , when page containing jquery ui tab loads, specific tab open depends on previous page. far, have down following:
php:
- obtain previous page using $_server['http_referer'];
- determine tab open using "if" statement (assigning tab_index variable);
- assign "tab_index" hidden input value.
javascript:
- pick hidden input value , assign js variable;
- ??
then not sure how make work in $('#tabs').tabs({.... statement. idea of how resolve appreciated. many thanks.
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 tab. we'll try fix possible."); } }, ...something here tab selection?... }); });
you can define active tab using
$(".selector" ).tabs({active: 2 });
meaning, code be, if understand tab_index correctly.
$('#tabs').tabs({ cache: false, active: tab_index, ajaxoptions: { error: function(xhr, status, index, anchor) { $(anchor.hash).html("couldn't load tab. we'll try fix possible."); } }, ...something here tab selection?... });
Comments
Post a Comment