Nav tabs keeping active after saving, among multiple tabs

Tab Selection Button
<li>
  <a data-toggle="tab" href="#tab_2" aria-expanded="false">
      <strong><i class="fa fa-building"></i> Building</strong>
  </a>
</li>

Tab Body
<div id="tab_2" class="tab-pane">
    <div class="results">
        <div class="table-responsive">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong style="line-height: 35px;"><i class="fa fa-home"></i> Park building details</strong>
                    <a class="buildingAddButton" data-toggle="modal" data-target="#ParkModal" onclick="openModal('.buildingAddButton', 'modal-content')" href="{{ url('/settings/park/create-building/'.Encryption::encodeId($park->id)) }}">
                        {!! Form::button('<i class="fa fa-plus"></i> <b>New building </b>', array('type' => 'button', 'class' => 'pull-right btn btn-default')) !!}
                    </a>
                    <div class="clearfix"></div>
                </div>
                <div class="panel-body">
                    <table id="buildingList" class="table table-striped table-bordered dt-responsive" cellspacing="0" width="100%">
                        <thead class="alert alert-info">
                        <tr>
                            <th>#</th>
                            <th>Building Name</th>
                            <th>Remarks</th>
                            <th>Status</th>
                            <th>Action</th>
                        </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

Tab Selection Script
$(document).ready(function(){
    var url = document.location.toString();
    if (url.match('#')) {
        $('.nav-pills a[href="#' + url.split('#')[1] + '"]').tab('show');
        $('.nav-pills a').removeClass('active');
    }
});

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine