jquery - Bootstrap data-toggle="tab" calling in a Javascript function -
i have little problem javascript code fail call in function. code is:
$('#mytabs a[href="#name"]').tab('show');
it works if not called in function. supposed toggle tabs working bootstrap framework. know how make compatible call in function?
edit:
function switch_tab() { $('#tablist a[href="#tab_default_2"]').tab('show'); }
does not work while work without function. (i'm not in javascript, if it's obvious, may not have seen it).
code of tablist :
<ul class="nav nav-tabs " id="tablist"> <li class="active" id="li_tab1"> <a href="#tab_default_1" data-toggle="tab" id="tab1"> situation administrative </a> </li> <li id="li_tab2"> <a href="#tab_default_2" data-toggle="tab" id="tab2"> demande de temps partiel </a> </li> <li id="li_tab3"> <a href="#tab_default_3" data-toggle="tab" id="tab3"> envoi de la demande </a> </li> </ul>
code of button :
<button class="btn btn-default" id="change_formulaire" onclick="switch_tab();" data-toggle="tab">valider</button>
and code of full function :
function switch_tab() { document.getelementbyid("tab1").disabled=true; document.getelementbyid("tab1").style.color="grey"; document.getelementbyid("li_tab1").classname="active"; document.getelementbyid("tab2").disabled=false; document.getelementbyid("tab2").style.color=""; document.getelementbyid("li_tab2").classname="active"; $('#tablist a[href="#tab_default_2"]').tab('show'); }
edit :
here solution : in function, can't switch tab if active. have make active (for display) after swiched.
function looks :
function switch_tab() { document.getelementbyid("tab1").disabled=true; document.getelementbyid("tab1").style.color="grey"; document.getelementbyid("li_tab1").classname="active"; document.getelementbyid("tab2").disabled=false; document.getelementbyid("tab2").style.color=""; $('#tablist a[href="#tab_default_2"]').tab('show'); document.getelementbyid("li_tab2").classname="active"; }
Comments
Post a Comment