mercredi 4 juin 2014

Bootstrap Tab Activation with URL


Vote count:

0




I have this for java script to activate a bootstrap tab on page load when the url looks like this this: /settings#update for example.



<script type="text/javascript">
$(function () {
var url = document.location.toString();
var url2 = url.split('#')[1];

var script = '#myTab a[href="#'+url2+'"]';

$(script).tab('show');

})
</script>


My html is this:



<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#general" data-toggle="tab" class="btn btn-primary"><?php echo __('settings:general') ?></a></li>
<li><a href="#identities" data-toggle="tab" class="btn btn-primary"><?php echo __("settings:business_identities") ?></a></li>
<li><a href="#update" data-toggle="tab" class="btn btn-primary"><?php echo __('global:update') ?></a></li>
</ul>
<div class="tab-content">
...
</div>


When this all runs, I get this error on this line: $(script).tab('show');



Uncaught TypeError: undefined is not a function


What does this mean?



asked 31 secs ago






Aucun commentaire:

Enregistrer un commentaire