jquery - Navigating to correct div using href with multiple tabs? -


i have multiple tabs in page each different id's created @ run time

<div class="span5" id="@model.id">          <ul class="nav nav-tabs">             <li class="active"><a data-toggle="tab" onclick="$('#@model.id #review').focus();">review</a></li>             <li><a data-toggle="tab" href="#@model.id #awesomediv1">web</a></li>             <li><a data-toggle="tab" href="#@model.id #awesomediv2">photos</a></li>             <li><a data-toggle="tab" href="#@model.id #awesomediv3">location</a></li>             <li><a data-toggle="tab" href="#@model.id #awesomediv4">map</a></li>         </ul> <div class="tabbable">             <div class="tab-content">                  <div class="tab-pane active" id="awesomediv1">                    .....                 </div> ... 

currently when change tab in of tabs first tab changes. want anchor tag navigate respective div of outer div. e.g. in jquery $('#1 awesomediv1') gives me correct div want navigate to. not seem working href.

the model coming asp.net mvc.

i solved using following

function activatecorrectdiv(parent, e) {         $('.tab-pane').removeclass('active');         $('#' + parent+ ' #' + e).addclass('active');     };  <a  data-toggle="tab" onclick="activatecorrectdiv(($(this).closest('div').attr('id')),'awesomediv1')"> 

the idea identify div needs active. make active , before ensure else not active. active css class btw. selector $(#parentid #childid) , notice space between them.

this may hack works !!


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -